PDA

View Full Version : VB.NET beginner problem



dbroada
5th May 2010, 11:05 am
I have installed microsoft's free Visual Basic 2010 Express in an attempt to look at using VB.NET with AutoCAD. I have followed an example I found on www.cadalyst.com (http://www.cadalyst.com) and have compiled my .dll file. I have now used NETLOAD to find the .dll but got this output...


Command: NETLOAD
Cannot load assembly. Error details: System.BadImageFormatException: Could not
load file or assembly
'file:///D:\DavesProjects\VB.NET(New)\HelloWorld\HelloWorld \HelloWorld\obj\Relea
se\HelloWorld.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:///D:\DavesProjects\VB.NET(New)\HelloWorld\HelloWorld \HelloWorld\obj\Relea
se\HelloWorld.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].

can anybody interpret this for me? Even nicer, can anyone suggest what I should do to progress?

Oh, and my machine has ONLY ever had AutoCAD 2008 Electrical on it, I cannot have picked up the references from the wrong install folder.

BIGAL
5th May 2010, 01:01 pm
Like you I am looking at going to .net the problem may be

"This assembly is built by a runtime newer than the currently loaded runtime"

Just a stab in the dark if VS is 2010 but autocad is 2009 then message makes sense need newer run time library for Autocad

The 2011 nightmare vba ? is about to start is it supported ? I am lucky we have some VS experts where I work but have not tapped into their help wil ask them tomorrow about this request (in AUS)

dbroada
5th May 2010, 01:49 pm
I wondered whether VS was too new for my version of AutoCAD but you have to add ACDBMGD.DLL & ACMGD.DLL as references into VS to (as I understand it) access the AutoCAD object. Since they were in the ACAD folder I had hoped they would be compatible with themselves! :)

We do hjave a couple of programmers here and I am sure at least one of them will know a bit about .NET but I'm the only AutoCAD person with ANY programming experience.

I am not desperate with this issue as the company (worldwide) standard is 2008 and is unlikely to change in the near future. What I am afraid of is that the next standard will be v201x without any VBA compatibility. I'm just trying to cushion the blow when (if) it comes.

As I understand it, VBA is no longer supported but can still be used with an AutoDesk download. I guess at some time they might drop that download and then we (here) will be in big trouble.

I have seen people here convert their VBA to VB.NET so I know it can be done :) but the forum search engine makes locating example very difficult!

dbroada
5th May 2010, 06:54 pm
I think the problem may be that I am compiling into net framework 4,0. I tried to compile to 3,5 just before I left work this evening but that still didn't work. Can anyone confirm what release of net framework I should be targeting with v2008?

and a sort of related question,

This is where my programming knowledge lets me down - how is the net framework added to AutoCAD?

BIGAL
6th May 2010, 03:32 am
I remember some articles about setting up the library links here

Do an advanced search for visual studio tick Vba lisps forum only, theres a lot of helpfull links that come up and I remember now theres a down load for Visual studio. It talks about setting up your VS.

I think I downloaded from the Autodesk site the files are called DE115-2 DE205-2 DE201-2 DE21-2 (allpdf's)

the first does the hello world tutorial so if that works your code should then work.

If you can not find them post here and I will email to you (200kb each)

dbroada
6th May 2010, 06:39 am
thanks, I'll have a look when I get to work.

The boss is in today so won't have quite as long to fiddle with coding today (he lets me, but not ALL the time)! :D

fixo
6th May 2010, 07:08 am
See post #3 (by articad) from there it may helps:
http://discussion.autodesk.com/forums/thread.jspa?messageID=6368245&#6368245

~'J'~

dbroada
6th May 2010, 08:02 am
Thanks Fixo - I discovered that last night too. It didn't fix my problem then but I may have rushed it and , well you know, something.

Anyway new day, new ideas. I'll keep trying (for now).

dbroada
6th May 2010, 08:20 am
WOOHOOO!!!!!

I had to compile to Net framework 2.0 to get it to load.

I am seeing lots of errors in the VS GUI but at least it loads and works now :D so I can start making a bit of progress.

SEANT
6th May 2010, 09:08 am
. . . .

I have seen people here convert their VBA to VB.NET so I know it can be done :) but the forum search engine makes locating example very difficult!



With regard to searching for .NET examples: It does seem like this forum's search function baulks at terms like VB.NET and/or C#. The word “transaction” is a fairly common term, though, and will return some hits for examples.

Also, the “Through the Interface” blog is an excellent resource for .NET programming within AutoCAD. This post, for instance, may be of some interest.

http://through-the-interface.typepad.com/through_the_interface/visual_basic/

fixo
6th May 2010, 09:41 am
WOOHOOO!!!!!

I had to compile to Net framework 2.0 to get it to load.

I am seeing lots of errors in the VS GUI but at least it loads and works now :D so I can start making a bit of progress.
Congrats :)

Keep trying

~'J'~

dbroada
10th May 2010, 12:57 pm
a slight update - I can compile to net framework 3.5 and all is well.

I can now at least write "Hello World" on the command line or on the screen. All I have to do now is find a project that requires it.....