Re: Detect if assembly exists

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



"William DePalo [MVP VC++]" wrote:
> For managed wrappers to the GAC interface:
>
> http://blogs.msdn.com/junfeng/articles/229649.aspx

Thank you! I needed that. It's a better resource then what I found.

> I'm not sure what your options are for assemblies outside of the GAC if, as
> you say, you don't want to load them.

Well, I have been thinking on that. And I think I have found a solution. Not
sure for that, so if someone could verify it?

I found out that I can get the AssemblyName of a .NET .dll file (aka
assembly) by simply calling the static method AssemblyName.GetAssemblyName().
The only parameter is a filename string.

The remarks of this method:
> This will only work if the file contains an assembly manifest. This method causes the file to be opened and closed, but the assembly is not added to this domain.

Now I only need to know the assemblies which the CLR would load in the
filesystem (not the GAC). I think I can determine the directory which the CLR
will try to search for the files by getting the AppDomain.BaseDirectory
property. However, does the CLR search in subdirectories? And ís this the
directory the in which the CLR will search?

With the directory I can search for .dll files, and try to get the
AssemblyName with the mentioned method.
And with the managed GAC interfaces I can search for the AssemblyName in the
GAC.

So this would be the answer to my question. But is it? Could someone verify
my solution?
.



Relevant Pages

  • RE: Why are assemblies loading from the GAC?
    ... Actually, this behavior is defined by the design of CLR probing logic, ... "How the Runtime Locates Assemblies" ... As you can see the CLR runtime will always check GAC before private ...
    (microsoft.public.dotnet.framework)
  • Re: Can not reuse mixed-mode functions in VC++
    ... By a mixed-mode function I mean a function whose signature has one or more CLR types and one or more non-CLR types. ... This worked fine, but because of the loader lock bug, I did not pursue my use of C++ mixed-mode programming in .NET assemblies. ... Trying the exact same thing I did in VS 2003, I now receive the error message telling me, for the mixed-mode functions, that a function with the clr calling convention can not be exported. ... In fact the native wrapper type has been defined as a private type for some good reasons. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Reflection permission denied
    ... In order for the CLR to know where your code came from, ... uses a host to give it information about your code. ... The CLR then performs a permission grant based on the evidence from ... >> assemblies are not allowed to create application domains. ...
    (microsoft.public.dotnet.security)
  • Complex Problem with AppDomains, Assembly Loading Contexts and COM Interop
    ... My team has been struggling with an issue involving assemblies ... extension running in a third party executable via COM Interop. ... C++ code (say to custom host a CLR). ... mechanism and end up in the default loading context. ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Using COM DLLs from SQL
    ... Your subject line says it's a COM dll, which means that all the CLR stuff is ... You have to add the assembly to the database. ... of assemblies loaded into the database. ...
    (microsoft.public.sqlserver.programming)