ReflectionOnlyLoad in Macro

N

NickP

Hi there,

I am trying to do a reflection only load of an assembly, within a new
appdomain, within a macro.

i.e.

create new app domain
instantiate class
run class
class does reflection only load of assembly
process info obtained from assembly
dispose of close
dispose of app domain

Unfortunately I am having difficulties instantiating an instance of the
class that does the reflection only load. The class is within "MyMacros".
So how would I load this class?

Dim pADnDomain As System.AppDomain =
System.AppDomain.CreateDomain("NewDomain")
Dim pOHeHandle As System.Runtime.Remoting.ObjectHandle =
pADnDomain.CreateInstance(<what assembly goes here?>,
"MyMacros.AssemblyBuildWorker")

I have no idea what assembly the class resides in, if it is within the
MyMacros namespace. Any ideas?

Nick.
 
N

NickP

Hi there,

Well, I now believe the following *should* work, but I guess I just
can't do this sort of thing inside of a Macro...

Dim pADnDomain As System.AppDomain =
System.AppDomain.CreateDomain("Labia")
Dim pAWrTempWorker As New AssemblyWorker
Dim pOHeHandle As System.Runtime.Remoting.ObjectHandle =
pADnDomain.CreateInstance(pAWrTempWorker.GetType.Assembly.GetName().FullName(),
"MyMacros.AssemblyBuildWorker")

I just get told it can't find the assembly, which is strange really, it
asks for the assemblies "display name" and the intellisense informs me that
the FullName property is also known as the "display name". Weird...

Nick.
 
N

NickP

BTW, The reason I am trying to do this in the first place, is that I have a
macro that updates the version numbers in all projects in my solution (C++
and VB.NET projects).

In order to update the numbers I am acquiring the current version number of
the main assembly in the solution. Unfortunately VS.NET doesn't always
unload this assembly correctly and I am informed that the assembly cannot be
loaded twice in the same application domain, this error happens
intermittently. So I thought the best way to get around it would be to load
the application into a separate application domain, and bobs your uncle.

But in practice that is seeming to be a bit of a g1t.

Nick.
 
N

NickP

Hmm very frustrating!

I had the idea of making a new macro helper class, and registering it with
the GAC. That way I could instantiate the class in another appDomain and
obtain the information that I require. Unfortunately the DLL will not show
up in the Macro add reference dialog, only a select number of assemblies are
visible!

Damn!

Can anyone recommend a good macro for customising version numbers in .NET
and C++ projects?

D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top