Re: Could not load file or assembly

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Oct 16, 11:19 pm, Terry Holland <MSDNNospam...@xxxxxxxxxxxxx>
wrote:
I am using the following code to execute a method of a class in an assembly

Public Shared Function NewPerson() As TZ_Interfaces.IPerson
            'This factory will return an instance of clsPerson with ID=intID
            'from the BLL assembly defined in BLLCustomAssembly setting

            Dim strType As String = BLLCustomAssembly '
My.Settings.BLLCustomAssembly

            Dim objPerson As TZ_Interfaces.IPerson = Nothing
            Dim objAssembly As Assembly = Nothing
            Dim objType As Type = Nothing

            objAssembly = Assembly.LoadFrom(strType & ".dll")
            objType = objAssembly.GetType(strType & ".BLL.clsPerson")

            'Invoke the NewPerson shared method of clsPerson
            Dim objMethodInfo As MethodInfo = objType.GetMethod("NewPerson",
System.Reflection.BindingFlags.[Static] Or BindingFlags.[Public])
            objPerson = objMethodInfo.Invoke(objType, Nothing)

            Return objPerson
        End Function

If my calling code is a WinForms app, this code works as long as the DLL is
in the bin\debug directory of the WinForms assembly.

When I try the same thing with my calling code being an ASP.Net app I get
the following error, even if the relevant dll is in the bin directory of the
web app

Could not load file or assembly 'file:///C:\Program Files\Microsoft Visual
Studio 8\Common7\IDE\~\Bin......

Advice appreciated

It seems to me that this DLL was dependent on another DLL which was
not present in the bin directory. It goes to C:\Program Files
\Microsoft Visual Studio 8\.... where ASP.NET account has no access
rights. When you run your code in a WinForms app you run it under your
own user account and this works.
.



Relevant Pages

  • How can two instances of my interop dll talk to each other?
    ... I have a winforms app that other third-party Access/Dephi/Vb6 etc apps need ... able to send and receive messages with a running instance of my winforms ... So both Access clients and my winforms app can add a reference to this dll, ... the dll will be listening to the socket and get the message. ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Protecting against type mismatch errors
    ... but the code would be in a DLL and the class would be called from Word ... so there's no possibility of controlling the calling code. ... other than by calling it from a Word template that I am supplying. ... Even tho the VBA project in that template will be password protected, ...
    (microsoft.public.dotnet.languages.vb)
  • proper use of codebase tag
    ... I have a .net 2.0 winforms app that references a MS DLL. ... it fails and says it can't find the DLL. ... Group Policy Management solutions at http://www.sdmsoftware.com ...
    (microsoft.public.dotnet.framework)
  • Calling VB.net from C++
    ... Defines the entry point for the DLL application. ... When I compile this I get the following message ... I tried my calling code in VS c ...
    (microsoft.public.vc.language)
  • Re: Calling managed code from C
    ... Eric Pearson wrote: ... The calling code won't know and won't care that those ... that at some point code in your managed C++ DLL will cause a deadlock. ...
    (microsoft.public.dotnet.framework)