Hi, Dave,

 

If you (rsp. your scripts) do not need to access the MSVCRT80.dll, why do you 
want to AddReference() it?

 

So if I understand correctly:

 

You want to load an assembly which depends on the native MSVCRT80.dll, and that 
former assembly does not load because the latter native library is not found?

 

Some points to check:

-          Is the MSVCRT80.dll in the library search path?

-          Can your assembly.dll be loaded via "normal" .NET means (e. G. C# 
code)?

 

Grüße,

Markus

 

Von: Dave Peterson [mailto:dpeter...@broadwaytechnology.com] 
Gesendet: Mittwoch, 29. Juni 2011 13:49
An: Markus Schaber; ironpython-users@python.org
Betreff: RE: [Ironpython-users] Assembly references: file does not exist?

 

Hi Markus,

 

But *I* don't need to access it, only the assembly I'm trying to load does.   
Surely you're not suggesting that I wrap that DLL so a pre-built assembly 
(linked with that DLL!) can call into it?

 

-- Dave

 

From: Markus Schaber [mailto:m.scha...@3s-software.com] 
Sent: Wednesday, June 29, 2011 12:40 PM
To: Dave Peterson; ironpython-users@python.org
Subject: AW: [Ironpython-users] Assembly references: file does not exist?

 

Hi, Dave,

 

As I wrote, it is not a managed library, and thus cannot be loaded like a .NET 
library.

 

You can use p/Invoke or cTypes to access it., or write a wrapper library in 
C++/CLI.

 

Grüße,

Markus

 

Von: Dave Peterson [mailto:dpeter...@broadwaytechnology.com] 
Gesendet: Mittwoch, 29. Juni 2011 13:33
An: Markus Schaber; Curt Hagenlocher; ironpython-users@python.org
Betreff: RE: [Ironpython-users] Assembly references: file does not exist?

 

Thanks Markus!    

 

Any chance you have any thoughts about why my assembly dll fails to load in ipy 
given all the referenced assemblies can be loaded (beyond the msvcr80.dll)?  
Note that I verified that clr.References shows each of these referenced 
assemblies having been loaded when I test loading them all explicitly.  

 

I'm kinda lost.

 

-- Dave

 

 

-- Dave

 

From: Markus Schaber [mailto:m.scha...@3s-software.com] 
Sent: Wednesday, June 29, 2011 12:26 PM
To: Dave Peterson; Curt Hagenlocher; ironpython-users@python.org
Subject: AW: [Ironpython-users] Assembly references: file does not exist?

 

Hi, Dave,

 

As far as I know, the MSVCR (MicroSoft Visual C Runtime) library is not a 
managed library, but a native library. Thus, it cannot be loaded like a .NET 
library, and ILSpy cannot parse it.

 

Grüße,

Markus

 

Von: ironpython-users-bounces+m.schaber=3s-software....@python.org 
[mailto:ironpython-users-bounces+m.schaber=3s-software....@python.org] Im 
Auftrag von Dave Peterson
Gesendet: Mittwoch, 29. Juni 2011 13:04
An: Curt Hagenlocher; ironpython-users@python.org
Betreff: Re: [Ironpython-users] Assembly references: file does not exist?

 

Thanks Curt.

 

ILSpy shows only the following references for my assembly dll.  

 

// mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// Microsoft.VisualC, Version=8.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a
// System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// System.Windows.Forms, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089
// System.Data, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089
// MSVCR80.dll
//   

I can use 'clr.AddReference' to load all of them in ipy just fine EXCEPT for 
the listed MSVCR80.dll.   Is the VS 2005 C runtime really an assembly or does 
this reference mean something else?  (Sorry for being a .NET noob)  Definitely 
no matter what paths I append or insert to the front of sys.path, or add the 
the windows env PATH -AND- no matter how I try to load this DLL using 
clr.<methods>, it refuses to load and I just get an error.

 

FWIW, if I try to load the msvcr80.dll directly in ILSpy, it displays an error 
about "System.BadImageFormatException: Format of the executable (.exe) or 
library (.dll) is invalid.   However, I don't believe the file is corrupt as 
I've tried the same on other versions of msvcr80.dll on my system and they all 
give this error though the programs the dll files are in seem to run just fine. 
 I'm guessing this isn't an 'assembly'. J

 

The other thing I note is that there appears to be an empty line in the 
references.  Could this be causing the error I'm seeing?  ILSpy seems to show 
in the tree under references a blank tree item that corresponds to this, so 
perhaps ipy's clr is just not coping well with this?

 

 

-- Dave

 

From: Curt Hagenlocher [mailto:c...@hagenlocher.org] 
Sent: Wednesday, June 29, 2011 2:12 AM
To: Dave Peterson; ironpython-users@python.org
Subject: Re: [Ironpython-users] Assembly references: file does not exist?

 

Arg; I see we've now adopted the annoying python.org convention of replies not 
going to the list by default. :(

 

You can use ILDASM, ILSpy or Reflector to see what assemblies yours is 
dependent on. Now that Reflector costs money, ILSpy is probably the best option 
for a quick check (though Reflector may be worth paying for if you do a lot of 
.NET development).

On Tue, Jun 28, 2011 at 8:52 AM, Dave Peterson 
<dpeter...@broadwaytechnology.com> wrote:

Hi Curt,

 

I had actually tried ( 1 ) below first.  That is, change my sample code to this:

        import sys

        sys.path.append(r"D:\path\to\my")

        import clr

        clr.AddReference('dll')

 

Which, while it changes the error message, still fails.   Here's the new error 
message:

                IOError: System.IO.IOException: Could not add reference to 
assembly dll

                   at IronPython.Runtime.ClrModule.AddReference(CodeContext 
context, String name)

                   at IronPython.Runtime.ClrModule.AddReference(CodeContext 
context, Object reference)

                   at IronPython.Runtime.ClrModule.AddReference(CodeContext 
context, Object[] references)

                   at 
Microsoft.Scripting.Interpreter.ActionCallInstruction'2.Run(InterpretedFrame 
frame)

                   .... 

 

I've tried ( 2 ) as well, and while some of the known dependencies load 
successfully - showing that the process works - some do not.  This could mean 
I'm confused on my dependencies - is there a tool which will show what 
assemblies a given assembly requires?

 

-- Dave

 

From: Curt Hagenlocher [mailto:c...@hagenlocher.org] 
Sent: Tuesday, June 28, 2011 3:11 PM
To: Dave Peterson
Subject: Re: [Ironpython-users] Assembly references: file does not exist?

 

.NET doesn't generally load dependent assemblies just because they're in the 
same directory from which you're doing a LoadFrom. I seem to recall that there 
are two ways of handling this:

 

1) Add the directory to sys.path and then use clr.AddReference (without the 
full path)

2) Explicitly load the dependencies first before loading the dependents.

On Tue, Jun 28, 2011 at 6:25 AM, Dave Peterson 
<dpeter...@broadwaytechnology.com> wrote:

Hello,

 

I'm relatively new to IronPython and .Net, but reasonably familiar with Python. 
  I'm trying to write a .py script to use one of my employer's .NET dlls but 
whenever I try to AddReferenceToFileAndPath() I get an error:

        IOError: System.IO.IOException: file does not exists: D:\path\to\my\dll

However, the DLL definitely exists at D:\path\to\my\dll and indeed works from 
there using my employer's app.   

 

I'm using the newest IronPython (just downloaded from the site and installed 
today using the installer):

        IronPython 2.7 (2.7.0.40) on .NET 4.0.30319.225

 

My latest attempted code is as below, though I've tried a lot of various 
combinations:

        import sys

        sys.path.append(r"D:\path\to\my")

        import clr

        clr.AddReferenceToFileAndPath(r"D:\path\to\my\dll")

 

That last line raises the exception mentioned above with a stack trace where 
the first two lines are both from the IronPython's ClrModule.  I may be barking 
up the wrong tree here, but it leads me to believe that my entry DLL is trying 
to load another DLL and the system can't find the other one, even though it is 
in the same directory as the first dll.   Here's the first two lines of the 
stack trace (I can't copy'n'paste off the work machine where this is happening 
due to security constraints.)

 

        at IronPython.Runtime.ClrModule.AddReferenceToFileAndPath(CodeContext 
context, String file)

        at IronPython.Runtime.ClrModule.AddReferenceToFileAndPath(CodeContext 
context, String[] files)

 

 

Thanks in advance,

 

-- Dave

 

 

 


_______________________________________________
Ironpython-users mailing list
Ironpython-users@python.org
http://mail.python.org/mailman/listinfo/ironpython-users

 

 

_______________________________________________
Ironpython-users mailing list
Ironpython-users@python.org
http://mail.python.org/mailman/listinfo/ironpython-users

Reply via email to