PDA

View Full Version : Visual Basic 2010 Express - Compile Using .NET 3.5?



BlackBox
18th Jan 2011, 02:59 pm
I am a Visual Studio noob, and have just began to dabble with VB.NET development.

I am running Visual Basic 2010 Express (sans VBCAD Template), AutoCAD Civil 3D 2011, Windows XP 32-Bit.

Going through the 'HelloWorld' tutorial, when I NETLOAD my .DLL, I get the following error:



Command: netload
Cannot load assembly. Error details: System.BadImageFormatException: Could not
load file or assembly 'file:///C:\Documents and Settings\%UserName%\My
Documents\Visual Studio
2010\Projects\HelloWorld\HelloWorld\bin\Release\He lloWorld.dll' or one of its
dependencies. This assembly is built by a runtime newer than the currently
loaded runtime and cannot be loaded.
File name: 'file:///C:\Documents and Settings\\%UserName%\My Documents\Visual
Studio 2010\Projects\HelloWorld\HelloWorld\bin\Release\He lloWorld.dll'
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase,
Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark,
Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase,
Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark,
Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyNa me assemblyRef,
Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence
securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm,
Boolean forIntrospection, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at Autodesk.AutoCAD.Runtime.ExtensionLoader.Load(Stri ng fileName)
at loadmgd()

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure
logging.
To turn this feature off, remove the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog].

Command: helloworld
Unknown command "HELLOWORLD". Press F1 for help.


Here is my code:



Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.Civil.Land
Imports Autodesk.Civil.Land.DatabaseServices


Public Class HelloWorld
<CommandMethod("HelloWorld")> _
Public Sub HellowWorld()
'Application.DocumentManager.MdiActiveDocument.Edi tor.WriteMessage("Hello World!")
MsgBox("Hello World!")
End Sub
End Class


Is this an issue of compiling using .NET 4.0 instead of 3.5? If so, how do I fix this?

Cheers!

Tyke
18th Jan 2011, 03:05 pm
Have you got .NET Framework 4.0 installed on your computer?

You could always try compiling for .NET Framework 3.5, it sounds awfully like a .NET Framework mismatch.

Good luck :wink:

BlackBox
18th Jan 2011, 03:20 pm
it sounds awfully like a .NET Framework mismatch.


...Looks like one too:
(Snapshot from Registry Editor)

25841


You could always try compiling for .NET Framework 3.5


How would one go about do that? :?

Tyke
18th Jan 2011, 04:12 pm
Open the Project Explorer
Right click on the project name and select properties
Go to the Compile Tab
Click on the button bottom left "Further compilation options" (I think, I only have a German version at work)
In the window that opens in the bottom drop down list you can select the .NET Framework version you want to compile to.
Rebuild your project and "Bob's your uncle"

BlackBox
18th Jan 2011, 04:28 pm
Open the Project Explorer
Right click on the project name and select properties
Go to the Compile Tab
Click on the button bottom left "Further compilation options" (I think, I only have a German version at work)
In the window that opens in the bottom drop down list you can select the .NET Framework version you want to compile to.
Rebuild your project and "Bob's your uncle"

Bob *IS* my uncle, and You are the Man. :wink:

If I ever make it to Saxony, the first yard of Erdinger Hefeweizen is my treat.

Prost! :stein:

Tyke
18th Jan 2011, 04:33 pm
Thanks, you're welcome.

Erdinger is Bavarian, here we drink Radeburger :roll: But Erdinger is a good substitute.

I'm done for today and off home to sink a couple of those Radeburgers.

BlackBox
18th Jan 2011, 04:43 pm
Thanks, you're welcome.

Erdinger is Bavarian, here we drink Radeburger :roll: But Erdinger is a good substitute.

I'm done for today and off home to sink a couple of those Radeburgers.




The Privatbrauerei Erdinger Weißbräu Werner Brombach GmbH (also known as Erdinger Weißbräu) is a brewery in Erding, Germany. Its best-known products are its namesake Weißbiers (white beer).



Well, what can this American say, other than bring on the Radeburgers! o:)

I'll have to see if I can get Radeburger here... Hmmm.

Many thanks! :)

Tyke
19th Jan 2011, 07:35 am
Have a look here:

http://en.wikipedia.org/wiki/Radeberger_Brewery

I don't like the look of that one in the background!!!