Solved

Make a C# wrapper for a managed assembly

Posted on 2013-01-20
4
338 Views
Last Modified: 2013-01-24
Before I begin, let me start my saying, I understand what I am asking for is very unusual
and not normally required.

I have a serial of assemblies, six in total.  The are true .Net assemblies. They are actually the Red-gate SQL Compare SDK  assemblies.

I have a license to use these, however, the license only allows me to build against them on one machine.  I actually have three computers which I use on a regular basis, and more than once have needed to recompile my app to fix a bug on a machine that does not have the license installed.

My solution to this, is, I wish to make a wrapper dll, that will allow me to have all the functionality of the original dlls.  I could then build this against the correct licence then use this dll as is, on all my computers, with the need to recompile it.

The Red-gate website actually suggest this as an option to prevent constant re-licensing.

My question is, as these assemblies have many classes, methods, enums, etc. is there a simple way to make this wrapper, without having to manually map every class, method, function, enum etc.

I know with COM+ I can use the .Net import tools, but I have never seen a tool to import a .Net assembly.

Any and all help is greatly appreciated.
0
Comment
Question by:townsma
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Orcbighter
Comment Utility
To simplify your problem:
You have a PC AAA on which is installed the Red-gate licence.
You have software that runs on three machines: AAA, BBB, and CCC
There is a bug in your software on BBB and you would like to rebuild your app on BBB.
1. Are you unable to replicate the bug on AAA, do the code-fix and then rebuild and then reship the software to BBB?

To proceed with your request implies that you will make a fix on BBB and rebuild on BBB, allowing the software on BBB to diverge from that on AAA and CCC. Is this correct?
0
 
LVL 6

Author Comment

by:townsma
Comment Utility
The purpose of the different machines is simple, I have a desktop in my office, I have a desktop at home and I have a laptop for when travelling.  All computers have VS2010 installed, along with the source code of my app.  But only the system at the office has the redgate sdk tools installed.  The other two computers have the redgate runtime files only.

If I need to do an urgent hot fix I may be at home, or I may be on a different customers site.  Either way I need to build the app again.  Because the redgate sdk is only on the office system, the build will fail.

So RedGates solution is to make a dll, that acts as a wrapper to their assemblies, this will be compiled on the office system, and the license will be embedded in the dll.  This built dll, along with it's dependent files, can then be copied to any other computer, and used in my app.

As the dll itself will not be rebuilding, the build of my app will succeed.

I hope this explains it better.

Thanks
0
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
Comment Utility
I'm not sure if there's any other way to do what you seek outside of wrapping every method you want to use from the API. The only other thing I can think to do would be to use Reflection, and there would be a performance penalty for that. You would have to judge whether or not this penalty was acceptable for your application.
0
 
LVL 9

Expert Comment

by:Orcbighter
Comment Utility
I agree, there seems no way to avoid making your own DLL with stubs for the APIs.
One good point is that the your dll only has to provide wrappers for those parts of the API that you actually used, not the entire Red-gate API.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now