 |
|
 |
I want to implment a plugin mechanism, assemblies are in a special file format, something like the way you implement(zip file), and I wish to handle the loading procedure of assemblies(resolve the paths to actual content etc, since the assemblies are actually in one single file)
is it possible to use your managed code to accomplish it?
Regards,
unruledboy_at_gmail_dot_com
http://www.xnlab.com
|
|
|
|
 |
|
 |
and nice implementation, keep coding!
|
|
|
|
 |
|
 |
Do you have any thoughts on the use of the NAR technique with assemblies that expose COM interfaces? The challenge here is that .NET appears to control the CLR/app domain used for COM so it not clear how a NAR technique could work but perhap you know a solution.
Bill Seddon
|
|
|
|
 |
|
 |
I'm working on this for the next release of the NAR Loader but unfortunately there are two problems: 1st a lack of time and 2nd my solution to this problem did not work as expected so I think it will take some time until I can integrate this into the NAR Loader.
|
|
|
|
 |
|
 |
Are you able to give me any clues? I'm in a position to help with a resolution if there is one. The problem I see is insurmountable (but then I wasn't aware that the NAR concept is possible!).
My scenario is that I have a .NET application that can be used by Excel. A shim implements Excel's COM Addin interface (that is it implements the IDTExtensibility2 interface). When invoked by Excel it creates an instance of the COM interface exposed by a .NET assembly. To do this, the assembly is registered as a COM automation server in the registry. But, of course, it's mscoree.dll that it registered as the handler. Conceptually mscoree.dll could be replaced by the NAR loader but the problem I see is that mscoree.dll seems to know how to marshall COM calls from any client to any server and NAR loader it seems would need to be able to replicate this behaviour.
On an unrelated point, the assembly that implements the COM interface is also used directly by another .NET assembly packages as a .exe. Is it possible to have two "entry points" to a NAR file? That is, one to access the COM interface and another to behave as a straight forward exe as it does today?
I shall be spending sometime making sure I understand the NAR loader and researching the functionality of mscoree.dll and maybe as a result I'll begin to understand whether implementing a COM interface via NAR is viable.
Finally, thanks for the article. It's an inspiration.
Regards
Bill Seddon
|
|
|
|
 |
|
 |
You are right - the best sollution would be a clone of mscoree's Com Callable Wrapper
(CCW) functionality which would relay COM calls to the NAR archive. How to do this right
has to be found out. Inside the NAR archive, in the archives manifest, assemblies
providing COM functionality can be listed with their typelib information so that the
loader can provide them to the COM client.
Another possible sollution would be to convert the loader into an ActiveX .exe which
provides some interfaces so that the loader itself can be used by any COM client -
this is easier to accomplish but not so flexible like the CCW sollution. For your
Excel example this means you have a standard COM addin and this addin calls the
loader via COM [ eg. Loader.Run(ArchiveName) or Loader.Call(Type, Method, Arguments) ]
and the loader itself does the rest.
Both described ways are just ideas (with a few lines of test code) for the moment.
If time permits I will keep on integrating a sollution into the loader but as it is
open soure feel free to play with it - and ideas and sollutions are welcome.
Regards
Richard
|
|
|
|
 |
|
 |
My thinking at the moment that the the way to try to implement a COM interface will be to copy the mechanism used by the COM Shims generated by the shim wizards. Initially, for me, using a specific interface will work, one that implements a fixed set of known methods just as happens with the add-in shims. In this way a COM interface method can be proxied the corresponding method of the assembly 1:1.
A future implementation can make heavy use of QueryInterface. The loader can be told (via information in the registry just like mscoree) what assembly it is to proxy. The loader can then create the domain (as it does now) load the primary assembly and use reflection to determine the COM interfaces it exposes and build a pseudo v-table for each entry point. The QueryInterface implementation can then return a pointer to the pseudo v-table for each uuid/dispid it recognises and then proxy any call using the pointer to the real, assembly, based method.
However, that's in the future. Right now I'm trying to understand why my NAR will not work. Your NARTest works OK. Stepping through NARLoader.exe I can see that my primary assembly is found, extracted and loaded OK but at the point supporting assmeblies should be loaded the narloadermanager assembly is requested again and then, bang, there's an exception. So I'm trying to work out why the narloadermanager assembly is requested a second time. This behaviour doesn't occur when NARTest is being used. Mmmm.
I was confused initially because the loader would not accept my primary assembly. It turns out the problem is that the GetMethod() in NARLoaderManager::Run() does not expect a public static Main() method and is instead expecting private Main method.
Is there any easy way to watch the NARLoaderManager?
Regards
Bill Seddon
|
|
|
|
 |
|
 |
ILMerge[^] should be good for most similar circumstances.
|
|
|
|
 |
|
 |
I cannot load a class by reflection in the compressed exe file, but NetZ able to do so.
|
|
|
|
 |
|
 |
Well - I just made a simple test loading an assembly via reflection, enumerating the types in it and calling a method and everything works as it should. The test was added to the test application for the loader 1.1 and can be downloaded at http://www.min.at/nar/Download/NARLoader.zip
Have you looked at the fusion log to see whats going wrong?
|
|
|
|
 |
|
 |
May I have a look on the source of this test project?
Maybe my coding has some problems, so it cannot work with NARLoader
|
|
|
|
 |
|
 |
Have a look at http://www.min.at/nar/Download/NARLoaderSource.zip. There you will find the
NARTest project which includes a reflection test.
But you should look at the fusion log before! There you will find all assembly resolve
or load issues - so this would be probably the faster way to solve your problem.
|
|
|
|
 |
|
 |
This tools saved my life in my current project (at work)!
|
|
|
|
 |
|
 |
And all in managed code?
Marc
XPressTierSome people believe what the bible says. Literally. At least [with Wikipedia] you have the chance to correct the wiki -- Jörgen Sigvardsson People are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer
|
|
|
|
 |
|
 |
NetZ has several limitations (for instance, unmanaged DLLs that the app might be calling). It would be a significant improvement if NARLoader handles those!
Herman Chelette
"Damn the specs! Find the elegant solution!!"
|
|
|
|
 |
|
 |
I think that NARLoader is simpler than NetZ and yes - it will handle unmanaged DLL's - in a future version - but not now. The next version of the NAR loader will provide standalone and password protected archives. After that I will target unmanged DLL's and data files.
|
|
|
|
 |
|
 |
Thanks, Richard
I am currently using ClickOnce on my dev machine, then doing a copy/paste routine to deploy a shrink-wrap version to customers. Lets see ... how do you spell "kludge"?
It will, though, install a Win32API dll if you add it to the project as an "existing item".
Herman Chelette
"Damn the specs! Find the elegant solution!!"
|
|
|
|
 |
|
 |
This is great but i can't seem to access the website for more details...
KJQ
|
|
|
|
 |
|
 |
There is a provider outage here right now - should be back soon (hopefully)
|
|
|
|
 |
|
 |
Unfortuantely i get a "ComException while parsing security.config ( path to it )XML, 0x80004003."
in NARLoader.cpp line 592.
It would be interesting to change this into some secure loader, with password support.
|
|
|
|
 |
|
 |
Can you send this security.config to me via private mail so that I can analyze it? I just tested it with the Debug und Release binaries in the download archive and did not get any errors. Did you bild your own binaries? Which Framework version? The NARLoader creates a backup file of the original security.config named security.config.NARLoader.backup.YYYYMMDD-hhmm so that you can revert to the original one.
|
|
|
|
 |
|
 |
Hello,
I have only started the release version you delivered in the Archive.
It tries to start my FW version v2.0.50727.
And I have checked the directory, and there is no such file for FW 2.0.
There are only the binary versions security.config.cch.
|
|
|
|
 |
|
 |
Hi,
The loader needs a security.config file where it can add it's CAS code group during install.
If there is no security.config but only a security.config.cch you can create one by just starting
Control Panel/Administrative Tools/Microsoft .NET Framework 2.0 Configuration
and closing it. After this you should have a security.config and can install the loader.
|
|
|
|
 |
|
 |
OK,
done that, it is working now.
|
|
|
|
 |
|
 |
sweet!
this looks like a very basic idea and a very basic tool. but the idea is awesome!
I'l look at the code when I get home and then rate it.
rara avis in terris
|
|
|
|
 |