subsonic object reference not set to object - subsonic

I created a site with the SubSonic Generator Website
I have done this before with few if any issues, however now I can generate and build the site in Visual Studio but I keep getting this error for any of the pages I generate
All of this code is generated I have not done anything to it.
Object reference not set to an instance of an object.
Line 216: Private Sub BindGrid(ByVal orderBy As String)
Line 217: Dim tblSchema As TableSchema.Table = DataService.GetTableSchema("Workers", "MsbcNurseryprov")
Line 218: If Not tblSchema.PrimaryKey Is Nothing Then
Line 219: Dim query As New Query(tblSchema)
Line 220: Dim sortColumn As String = Nothing
When I build the site in visual studio I do not get any errors

never mind it was a permissions issue with my sql account! too bad I spent 2 hours trying to figure it out since this error was useless to indicate this to me!

Related

Changing the location of a referenced library

I have a C# Library which I use in an Excel VBA project. I wish now wish to restructure my project and want to move the library to a different folder. However after removing the reference to the library and deleting all instances of the library from my computer, the References Available box for the project still shows the reference to the old library location even though it no longer exists on the computer and nothing I do seems to be able to remove that reference.
I don't know if this makes any difference, but the project is an Excel AddIn.
I had this problem back in 2019, and received a response to a question with the same title in April 2019. On that occasion the the issue was resolved by following the advise given. However this time the system stubbornly refuses to play ball.
The procedure that I was advised to follow in 2019 was:
Remove the reference
Save the File and close it
Delete the dll (in my case the .tbl) file from your computer. Do not save it anywhere.
ReOpen the file
Check if there is any reference still there. If not copy the dll to a new folder and then set a reference again. Save and close the file.
ReOpen to check if everything is OK
I was going to try code to remove the reference, but the following code did not find the reference
Sub delRef()
deleteReference ("FiskDLLlib")
End Sub
Sub deleteReference(s As String)
Dim oFs As Object, oReferences As Object, oReference As Object
Dim sFileName As String, sRefName As String, sRefFileName As String
Dim toBeDeletedRef As String
Set oReferences = Application.Workbooks("fiskAIWkBook.xlam").VBProject.References
For Each oReference In oReferences
sRefFileName = oReference.FullPath
sRefName = oReference.name
If sRefName = s Then
toBeDeletedRef = s
Exit For
End If
Next
If toBeDeletedRef <> "" Then
Debug.Print oReference.FullPath
Else
Debug.Print "No Reference found for " & s
End If
End Sub
Similarly the Watches panel didn't show the library.
I have subsequently discovered a registry key
\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib{B22F6C9D-53E0-4D1B-9596-56AA1EA4BDBA}\1.0\0\win32
the value of which was set to the location of the reference I am trying to remove. I changed this to a reference to the new location in which I want to store my dll (.tlb) file. This at least looked like it would allow me to create a new reference in the References box but on clicking OK I got a message saying "Error in loading DLL"
I resolved my problem in the end by removing all references to the library in the Registry with a registry Cleanup tool (ReImage) before copying the library to its new directory and then reregistering it with regASM

Trying to get clipboard data

I'm trying to get clipboard data through this lines:
Sub GetClipboard()
Dim objData As New MSForms.DataObject
Dim strText
objData.GetFromClipboard
strText = objData.GetText()
MsgBox strText
End Sub
I get the error:
"User-Defined type not defined"
While "Microsoft Office 16.0 Object Library" is selected in Tools> Reference!
Appreciate any help on this.
It looks like you are missing the correct reference.
In this case for the MSForms namespace you need the Microsoft Forms Object Library (e.g. Microsoft Forms 2.0 Object Library reference).
On my installation of Office 2016 I do not have this library that I could reference. But as stated here (https://wellsr.com/vba/2015/tutorials/vba-copy-to-clipboard-paste-clear/) there are problems since Windows 8/10 anyway. The solution is to use the Windows API directly. Which should work on Windows 7 and newer.
In the first link there is an example only for setting data to the clipboard. You asked for retrieving data so a quick internet search revealed this example code which is described as working on Windows x86 and x86_64 and supports setting and getting data from the clipboard (https://francescofoti.com/2013/12/share-the-clipboard-with-vba-and-the-windows-api/).
I have tested the code from the second link to retrieve a string from the clipboard and it worked. I had to fix a minor thing. The Application object on my Office installation does not have a member called hWndAccessApp. One has to replace it with the default hwnd member:
Application.hWndAccessApp
replaced with:
Application.hwnd
You need below
set objData = New MSForms.DataObject

I receive "Object LIbrary feature not Supported" on Evernote SDK VBA sample at ListNotebooksForCOM()

I installed the Windows SDK, opened the sample spreadsheet and checked the reference to "Evernote Cloud SDK for Windows". I get the error when I run the VBA macro
This is the sample code:
Sub EvernoteSDKSample()
Dim EvernoteSession As New ENSessionForCOM
' Be sure to put your own consumer key and consumer secret here.
Call EvernoteSession.SetSharedSessionConsumerKey("hhagell", "3da657d6f5855f7b")
If EvernoteSession.sharedSession.IsAuthenticated = False Then
Call EvernoteSession.sharedSession.AuthenticateToEvernote
End If
' Get a list of all notebooks in the user's account.
Dim myNotebooks As ENCollection
Set myNotebooks = EvernoteSession.sharedSession.ListNotebooksForCOM()
I found a couple of people had the same error and did not find a resolution (at least one not documented)
Any thoughts would be appreciated.
Cheers
Any thoughts would be appreciated.

VBA Dim Object error

If I Run
Sub test()
Dim Template_Excel_Instance As excel.application
Set Template_Excel_Instance = CreateObject("excel.application")
End Sub
my code breaks with an error "Automation Error, Library not registered"
If I run
Sub test()
Dim Template_Excel_Instance As object
Set Template_Excel_Instance = CreateObject("excel.application")
End Sub
It runs fine. Is there any way to fix this? Reason I ask is that this issue only affects one PC, despite having the same references as all other PCs. The first error is not coming up anywhere else
Does that PC have a different version of Excel?
The problem is with As Excel.Application. If you don't have the appropriate reference defined, then the VBA compiler will not recognise the type. Yes, VBA does have a compilation step. If you do have the reference defined, then this is sensitive to the application version (just the major part of the application version I think), so is therefore inherently non-portable.
In your latter example, you are using late binding, so only COM object registration is required, not any specific library to be added to your project. For portability, this is the way to go.
Firstly, have you tried repairing the install?
Secondly, is there a reason you are instantiating a second instance of Excel?
Thirdly, let's get a grip on what is happening, please run this code and report back.
Option Explicit
Sub TestWhatVersionDoesCreateObjectReturn()
Dim obj As Object
Set obj = CreateObject("Excel.Application")
Debug.Print obj.Version
End Sub
Sub TestWhatOtherVersionsAreCreatable()
Dim lLoop As Long
For lLoop = 7 To 16
Dim obj As Object
Set obj = Nothing
On Error Resume Next '///set break on unhadnled errors
Set obj = CreateObject("Excel.Application." & CStr(lLoop))
On Error GoTo 0
If Not obj Is Nothing Then Debug.Print obj.Version
Next
End Sub
Also, look for multiple installations of Excel. The code at this blog page will read your registry and write the results to an Excel worksheet. You say you have repaired the install but there might be other Excel installations interfering. The code in that blog will highlight multiple Excel installs.
Ok, from your feedback you say all the Excel libraries version return 14, implying no multi version installs. Hmmm, we ought to consider that actually the library that error is complaining about isn't Excel but a dependency.
Other possible leads
Social MSDN - automation error. Library not registered - solved by cleaning registry of legacy "Microsoft.Office.Interop.Excel" keys

"User-defined type not defined" error in Excel VBA after upgrade to Windows 10

A co-worker developed a part of Excel VBA-code for me. This code I have integrated in my code.
Both parts of code separate runs fine at Windows 7.
Both parts of code separate runs fine at Windows 10.
Both parts of code integrated runs fine at Windows 7.
Although both parts of code integrated give an error at Windows 10.
The error is a Compile error "User-defined type not defined" directly after opening the file. It is caused by the line "Public objhttp As New XMLHTTP".
Option Explicit
Public objhttp As New XMLHTTP
Public url1 As String
Public src As String
'*******regualr Expression Variables*******
Public regx As New RegExp, matches As Object, match As Object
I have checked all the references under Tools in the Library from VBA.
The installed references are the same in all 4 situations. In all situations I use Excel 2016.
Do you know what can be the cause for this?
Thank you!
I had a very similar problem when Windows 10 rolled out where I work. Something to do with their initial OoTB build of Windows 10 not including a particular msxml dll.
I fixed a few workbooks that this broke by replacing all of these:
MSXML.XMLHTTP
MSXML.ServerXMLHTTP
MSXML.DOMDocument
with these:
MSXML2.XMLHTTP60
MSXML2.ServerXMLHTTP60
MSXML2.DOMDocument60

Resources