Jump to content

VB.NET beginner problem


dbroada

Recommended Posts

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 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(AssemblyName 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(String 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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

. . . .

 

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/

Link to comment
Share on other sites

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'~

Link to comment
Share on other sites

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.....

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...