all groups > dotnet clr > january 2004 >
You're in the

dotnet clr

group:

Compile an assembly with a reference to an in-memory assembly



Compile an assembly with a reference to an in-memory assembly Ray Johnson
1/30/2004 12:31:15 PM
dotnet clr:
I'm trying to compile an assembly in memory (kind of a plugin thing) that
references another assembly in memory.

Unfortunantly, the CompilerOptions object only has an argument like this:
parameters.ReferencedAssemblies.Add("System.DLL");

where the assembly must be on disk.



Is there a way to reference an assembly that is only in memory?



Ray

Re: Compile an assembly with a reference to an in-memory assembly Sankar Nemani
1/30/2004 1:56:26 PM
I've had a similar problem. I am trying to compile an assembly that
references another assembly that is downloaded during a smartclient run.
I have a theory that "may" work.
All assemblies including the in-memory ones do reside on the disk. The
in-memory assemblies may reside in some temp location. You can find out the
location of any such assembly using the Location property of the assembly
class.
Once you have the location property you can use that path when you add
assembly references using the parameters.ReferencedAssemblies.Add method.

Lemme know if it worked.
Sankar


[quoted text, click to view]

Re: Compile an assembly with a reference to an in-memory assembly Ray Johnson
1/30/2004 3:42:53 PM

Actually, I tried that. The Location property of an in-memory assembly is
the Empty string.

I even tried to get the assemblies from the AppDomain like this:
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())

{

string loc = asm.Location;

parameters.ReferencedAssemblies.Add(loc);

}

In this case it "almost" work. The code actually compiled. However, when I
tried to run the code I got the following exception:

Error: unexpected exception: File or assembly name kygy0xbi, or one of its
dependencies, was not found.

which I "assume" is my previosly generated assembly that it compiled
against. the name is different each time which is why I think it must be
the referenced in memory assembly.

So at this point I'm not sure if this is the right approach. If it is, I'm
not sure what to do to work around the fact it can't find it after it
compiles against it...

Ray

[quoted text, click to view]

Re: Compile an assembly with a reference to an in-memory assembly Sankar Nemani
1/30/2004 5:18:57 PM
So are you saying in ur second approach the location property is not an
empty string?

[quoted text, click to view]

Re: Compile an assembly with a reference to an in-memory assembly Ray Johnson
1/30/2004 5:55:54 PM

Actually, it finds ones with empty strings as well as well as ones with
these temp
names. Very weird.

Starting to think I'll be forced to write the assembly out to disk and write
additional
code to manage a directory of temporary assemblies. Kind of messy if you
ask me.

I'd much rather like to know how to reference the assemblies in memory...

Ray

[quoted text, click to view]

AddThis Social Bookmark Button