Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
AnswerRe: control invisible Pin
Boipelo7-Apr-13 15:22
Boipelo7-Apr-13 15:22 
QuestionImproving performance of C# program when run from network drive Pin
eljainc5-Apr-13 5:04
eljainc5-Apr-13 5:04 
AnswerRe: Improving performance of C# program when run from network drive Pin
Dave Kreskowiak5-Apr-13 6:32
mveDave Kreskowiak5-Apr-13 6:32 
AnswerRe: Improving performance of C# program when run from network drive Pin
Jason Gleim5-Apr-13 10:33
professionalJason Gleim5-Apr-13 10:33 
GeneralCast COM object with reflection Pin
Member 99653115-Apr-13 0:04
Member 99653115-Apr-13 0:04 
GeneralRe: Cast COM object with reflection Pin
BobJanova5-Apr-13 5:12
BobJanova5-Apr-13 5:12 
GeneralRe: Cast COM object with reflection Pin
Member 99653115-Apr-13 5:21
Member 99653115-Apr-13 5:21 
GeneralRe: Cast COM object with reflection Pin
Jason Gleim5-Apr-13 10:51
professionalJason Gleim5-Apr-13 10:51 
Casting unmanaged objects to managed objects is a daunting task even when things are working properly. And you aren't getting any help if the 3rd-party is changing method signatures between API revisions. That is a cardinal no-no for exactly this reason.

If I had to do this, I would use a mechanism similar to discovering and loading a plug-in at runtime. (And there are articles on CP on how to do that) I would create an interface library that defines a new interface that harmonizes the difference between the two API's. (calling it the harmonized interface) In my application, I would reference that library and use those interfaces in code. Then, I would use the tlbimp tool to generate an initial interop assembly or write my own interop assemblies that will wrap the calls to the specific API versions exposing an object that implements the harmonized interface. The connector libraries would then be responsible for the heavy lifting of marshaling the calls from the harmonized interface to the underlying API-specific objects. In most cases, this should be simply pass-thru type calls but where there are differences I would handle those in an API-specific way in each of these connector libraries.

At runtime, I would need code which detects the correct version of the outside API and loads the appropriate connector library instantiating my interop class(es). Since they implement the common, harmonized interface, my app code would be consistent and the specifics of the underlying API differences are handled in the correct connector library. Where needed, I would use the underlying API version I detected to call (or not call) certain methods on the harmonized interface as appropriate.

The advantage of this approach is that when the API vendor screws you again with a new version that breaks the current API, you can simply write a new connector library and everything continues to work. If new functionality is added, expand the harmonized interface, implement those new methods in ALL of the connectors, but throw exceptions in the ones where the underlying API doesn't support the new functionality.
GeneralRe: Cast COM object with reflection Pin
Bernhard Hiller7-Apr-13 20:55
Bernhard Hiller7-Apr-13 20:55 
QuestionAbout webcam application Pin
Bishwajit Nepali4-Apr-13 23:56
Bishwajit Nepali4-Apr-13 23:56 
AnswerRe: About webcam application Pin
Abhinav S5-Apr-13 0:47
Abhinav S5-Apr-13 0:47 
QuestionInsert img into sql without using sqlparameter Pin
mohammadkaab4-Apr-13 22:04
mohammadkaab4-Apr-13 22:04 
AnswerRe: Insert img into sql without using sqlparameter Pin
Eddy Vluggen4-Apr-13 22:31
professionalEddy Vluggen4-Apr-13 22:31 
GeneralRe: Insert img into sql without using sqlparameter Pin
mohammadkaab4-Apr-13 22:51
mohammadkaab4-Apr-13 22:51 
AnswerRe: Insert img into sql without using sqlparameter Pin
Eddy Vluggen4-Apr-13 22:55
professionalEddy Vluggen4-Apr-13 22:55 
GeneralRe: Insert img into sql without using sqlparameter Pin
mohammadkaab4-Apr-13 23:05
mohammadkaab4-Apr-13 23:05 
GeneralRe: Insert img into sql without using sqlparameter Pin
Eddy Vluggen5-Apr-13 0:29
professionalEddy Vluggen5-Apr-13 0:29 
GeneralRe: Insert img into sql without using sqlparameter Pin
Richard Deeming5-Apr-13 1:41
mveRichard Deeming5-Apr-13 1:41 
GeneralRe: Insert img into sql without using sqlparameter Pin
BobJanova5-Apr-13 5:15
BobJanova5-Apr-13 5:15 
GeneralRe: Insert img into sql without using sqlparameter Pin
Keith Barrow5-Apr-13 2:44
professionalKeith Barrow5-Apr-13 2:44 
GeneralRe: Insert img into sql without using sqlparameter Pin
Jason Gleim5-Apr-13 11:01
professionalJason Gleim5-Apr-13 11:01 
AnswerRe: Insert img into sql without using sqlparameter Pin
cursore844-Apr-13 23:25
cursore844-Apr-13 23:25 
Questionc# exchange server 2007 set user properties Pin
Member 97066334-Apr-13 20:52
Member 97066334-Apr-13 20:52 
QuestionDll sharing and autoupdate application Pin
jp19814-Apr-13 20:14
jp19814-Apr-13 20:14 
AnswerRe: Dll sharing and autoupdate application Pin
Eddy Vluggen4-Apr-13 22:29
professionalEddy Vluggen4-Apr-13 22:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.