|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
static library in c# library controlcontaining a form which in turn contains a Windows application that I have defined in another library. I'm able to do it if my application which I put in the form is a c++ dll like so: [DllImport ("C:\\MyApp.dll")] private extern static void RunMyApp(IntPtr handle); private void InitializeComponent() { this.Name = "MyControl"; this.Size = new System.Drawing.Size(480, 640); RunMyApp( this.Handle); } However, my requirements now dictate that the application I want to put in this form is contained in a static c++ library. I have not been able to import the static library into the control. This is literally the only function that I need to call from my static library application. Is there a way to do this? Hi,
To the best of my knowledge, you cannot use static C++ libraries from C# code. What you can do however is to conjure up a very simple C++ dll exporting just one function, and within that function you will call whatever you need from the C++ static library. Then, use the resultant DLL from your C# code through the regular DllImport attribute. -- Show quoteSincerely, Dmytro Lapshyn [Visual Developer - Visual C# MVP] "newest newbie" <newestnew***@discussions.microsoft.com> wrote in message news:F8B9533C-8FE0-4E93-AE6B-2FA725279498@microsoft.com... > I'm new to using c#, but what I'm trying to do is create a library control > containing a form which in turn contains a Windows application that I have > defined in another library. > > I'm able to do it if my application which I put in the form is a c++ dll > like so: > > [DllImport ("C:\\MyApp.dll")] > private extern static void RunMyApp(IntPtr handle); > > private void InitializeComponent() > { > this.Name = "MyControl"; > this.Size = new System.Drawing.Size(480, 640); > RunMyApp( this.Handle); > > } > > However, my requirements now dictate that the application I want to put in > this form is contained in a static c++ library. I have not been able to > import the static library into the control. This is literally the only > function that I need to call from my static library application. Is > there a > way to do this? > > Thanks for the response :)
However, the reason I need to use a static library is because my end result is a web application and if I were to use a .dll then the web application expects the .dll on the users machine.... I'm now looking into an ActiveX control. If anyone knows another way around it, then please let me know! On the user machine? Why? If the DLL is used only on the server side, there
is absolutely no need to have it on the client. -- Show quoteSincerely, Dmytro Lapshyn [Visual Developer - Visual C# MVP] "newest newbie" <newestnew***@discussions.microsoft.com> wrote in message news:5C260C44-75D8-4C88-B6E0-194578BAFC28@microsoft.com... > Thanks for the response :) > > However, the reason I need to use a static library is because my end > result > is a web application and if I were to use a .dll then the web application > expects the .dll on the users machine.... > > I'm now looking into an ActiveX control. > > If anyone knows another way around it, then please let me know! > On the user machine? Why? If the DLL is used only on the server side, there When I use a dll in the way I first mentioned in a control library form and > is absolutely no need to have it on the client. then place that control in a web application, the control looks for the dll on the clients machine. I'm not experienced with this topic, is there a way to specify that the dll is on the server? Thanks for your help Ah, in this scenario - yes, the DLL is required on the client :-(
Therefore, I'd either write the whole control in C++ (by using ATL for example), or I would have to rewrite the static library in managed code. BTW: managed Windows Forms controls require IE 6 and .NET Framework on the client side. BTW2: The control *might* automatically download necessary DLLs, but I am not sure which permissions are required for it to do so. What I do remember is that the DLL must be on the same server and most likely in the same virtual folder. See no-touch deployment docs in MSDN for more information. -- Show quoteSincerely, Dmytro Lapshyn [Visual Developer - Visual C# MVP] "newest newbie" <newestnew***@discussions.microsoft.com> wrote in message news:EF126B85-0FFE-4A07-A3E8-6F27C06759C7@microsoft.com... >> On the user machine? Why? If the DLL is used only on the server side, >> there >> is absolutely no need to have it on the client. > > > When I use a dll in the way I first mentioned in a control library form > and > then place that control in a web application, the control looks for the > dll > on the clients machine. I'm not experienced with this topic, is there a > way > to specify that the dll is on the server? > > Thanks for your help Thanks again - I've started looking into no-touch deployment. That looks
like an option, but I'm not sure yet. I have also started to make the control in C++, but I'm getting nasty linker errors. I've also started trying to put the application in an ActiveX control, but I'm getting runtime problems from a graphics library I'm using. Nothing's easy I guess :P Thank you very much either way! Show quote "Dmytro Lapshyn [MVP]" wrote: > Ah, in this scenario - yes, the DLL is required on the client :-( > Therefore, I'd either write the whole control in C++ (by using ATL for > example), or I would have to rewrite the static library in managed code. > > BTW: managed Windows Forms controls require IE 6 and .NET Framework on the > client side. > BTW2: The control *might* automatically download necessary DLLs, but I am > not sure which permissions are required for it to do so. What I do remember > is that the DLL must be on the same server and most likely in the same > virtual folder. See no-touch deployment docs in MSDN for more information. > > -- > Sincerely, > Dmytro Lapshyn [Visual Developer - Visual C# MVP] > > > "newest newbie" <newestnew***@discussions.microsoft.com> wrote in message > news:EF126B85-0FFE-4A07-A3E8-6F27C06759C7@microsoft.com... > >> On the user machine? Why? If the DLL is used only on the server side, > >> there > >> is absolutely no need to have it on the client. > > > > > > When I use a dll in the way I first mentioned in a control library form > > and > > then place that control in a web application, the control looks for the > > dll > > on the clients machine. I'm not experienced with this topic, is there a > > way > > to specify that the dll is on the server? > > > > Thanks for your help > > |
|||||||||||||||||||||||