Package the ocx into the .Net executable |
Post Reply |
Author | |
Wael
Newbie Joined: 22 June 2005 Location: United Kingdom Status: Offline Points: 3 |
Post Options
Thanks(0)
Posted: 22 June 2005 at 10:52pm |
Hi I am new to using Activex with .Net and you probablly can tell from asking the following question:- Is it possible to package [i.e embedd] the CommandBars.ocx into my .net application exe file? if yes and I hope its a yes:- Is it possible to register the ocx once the application is started and unregisters once the application has been terminated. I am aware microsoft has a new tool called ILMerge that allows the merging of .net dll assembilies with exe's but it does not support ocx. I have found one other tool but have not tested it because my project is in csharp and it seems to have been developed for VB.NET. VB-PowerWrap 4.0 http://www.moonlight-software.com/ I hope there is a way to do this, so please let me know if you have any ideas. Thanks in advance. Edited by Wael |
|
Wael
Newbie Joined: 22 June 2005 Location: United Kingdom Status: Offline Points: 3 |
Post Options
Thanks(0)
|
well in case anyone is interested in the progress of this issue, Here is something maybe someone can work with, the following allows you to register/unregister the ocx dynamically. But the catch is that the ocx file will be treated as an external file and not embedded. hopfully there is still a way to do this while the file is being embededd. using System; public ocxRegServer(byte[] dllFile) public void Register() public void UnRegister() private void InternalRegServer(bool fUnreg) int hr = (int) m_tDllReg.InvokeMember ( sMemberName, private void CreateDllRegType() if (myModuleBuilder == null) AssemblyName myAssemblyName = new AssemblyName(); AssemblyBuilder myAssemblyBuilder = appDomain.DefineDynamicAssembly(myAssemblyName,AssemblyBuild erAccess.RunAndSave); myModuleBuilder = myAssemblyBuilder.DefineDynamicModule(myAsmFileName, &n bsp; myAsmFileName); // this line will embed the embedded CommandBars.ocx into the dynamically created assembly file myAssemblyBuilder.Save(myAsmFileName); // Add class to module MethodBuilder meb; // Add PInvoke methods to class // Apply preservesig metadata attribute so we can handle return HRESULT ourselves meb = tb.DefinePInvokeMethod( "DllUnregisterServer", // Apply preservesig metadata attribute so we can handle return HRESULT ourselves // Create the type // here is the code that goes into Form1 for usage:- private void InitializeComponent() // get the resource into a stream byte[] bStr = new Byte[str.Length]; ocxRegServer reg = new ocxRegServer(bStr); |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |