Solved

Make a C# wrapper for a managed assembly

Posted on 2013-01-20
4
343 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
ID: 38800801
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
ID: 38800885
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 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 38801343
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
ID: 38808743
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 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