Jump to content


Photo
- - - - -

Exception thrown when trying to load shell32.dll with .NET

.net external code assembly .dll

  • Please log in to reply
6 replies to this topic

#1 for(imstuck)

for(imstuck)

    Very Active

  • Members
  • PipPipPip
  • 151 posts
  • Location:Texas
  • Version:LabVIEW 2012
  • Since:2008

Posted 13 April 2012 - 03:00 PM

I am trying to open shell32.dll with .NET but an exception is being thrown. I'm seeing this type of exception all over when I search google but really not much related to LabVIEW (mostly vb.net, c#.net etc). I have tried loading shell32.dll from system32/shell32.dll and SysWOW64/shell32.dll and both fail. I am running 32 bit LabVIEW on Windows 7 64 bit. I'm guessing it has something to do with that. I am going to try on a coworkers 32 bit computer when I get a chance, but does anyone have suggestions?

Thanks.

Edit: Tried on 32 bit labview on a 32 bit machine and it still fails.

Attached Thumbnails

  • dotnetException.png

Edited by for(imstuck), 13 April 2012 - 03:14 PM.

CLA (but still always learning)

#2 GregR

GregR

    More Active

  • NI
  • 47 posts
  • Location:Austin
  • Version:LabVIEW 2011
  • Since:1992

Posted 13 April 2012 - 04:00 PM

Not all dlls contain .NET metadata so they can't be loaded as .NET assemblies. I believe shell32 would be one of those. You would need to use LoadLibrary from the Win32 API to load it. Also you should just load it by name. The system will locate the appropriate copy.

#3 for(imstuck)

for(imstuck)

    Very Active

  • Members
  • PipPipPip
  • 151 posts
  • Location:Texas
  • Version:LabVIEW 2012
  • Since:2008

Posted 13 April 2012 - 04:26 PM

Not all dlls contain .NET metadata so they can't be loaded as .NET assemblies. I believe shell32 would be one of those. You would need to use LoadLibrary from the Win32 API to load it. Also you should just load it by name. The system will locate the appropriate copy.

Thanks, I will go the CLFN route.
CLA (but still always learning)

#4 asbo

asbo

    I have no idea what you're talking about... so:

  • V I Engineering, Inc.
  • 1,273 posts
  • Version:LabVIEW 2011
  • Since:2008

Posted 14 April 2012 - 03:01 PM

Not all dlls contain .NET metadata so they can't be loaded as .NET assemblies. I believe shell32 would be one of those. You would need to use LoadLibrary from the Win32 API to load it. Also you should just load it by name. The system will locate the appropriate copy.

Agreed, shell32.dll is not a dot NET assembly. I think there's an assembly viewer tool that comes with Visual Studio which would could point at any given DLL to check with, but I don't know of anything that comes with Windows off-hand.

#5 for(imstuck)

for(imstuck)

    Very Active

  • Members
  • PipPipPip
  • 151 posts
  • Location:Texas
  • Version:LabVIEW 2012
  • Since:2008

Posted 16 April 2012 - 10:24 PM

You guys were right, but luckily there's the int->pointer function in .NET which allows you to get away from the CLFN rather quickly after making the initial call (at least in the case of grabbing icons from a dll).

Attached Thumbnails

  • inttopointer.png

CLA (but still always learning)

#6 rolfk

rolfk

    LabVIEW Aficionado

  • Premium Member
  • 2,050 posts
  • Location:Netherlands
  • Version:LabVIEW 2011
  • Since:1992

Posted 18 April 2012 - 02:20 PM

Wow iterating over Pixels in a loop through .Net calls. You only can hope that icons never get bigger than 48 * 48 pixels or that function is going to be soooooooooo sloooooooooooow.

Instead there are ready made LabVIEW VIs in vi.lib/platform/icon.llb that use exclusively Windwos API calls and are not just factors faster than your solution.

#7 for(imstuck)

for(imstuck)

    Very Active

  • Members
  • PipPipPip
  • 151 posts
  • Location:Texas
  • Version:LabVIEW 2012
  • Since:2008

Posted 18 April 2012 - 08:16 PM

Yeah, I am not actually using this (luckily) it was just a thrown together example. But, I will remember that in the future because the speed (or lack there of) didn't even cross my mind. Not to mention, I didn't realize that library existed.

Edited by for(imstuck), 18 April 2012 - 08:27 PM.

CLA (but still always learning)





Also tagged with one or more of these keywords: .net, external code, assembly, .dll