Two interops of same name in one project
I have two versions of a third-party com library. They are identical in namespace, but one is built to work with devices of X model, while the other works with Y model hardware. If I use the wrong library I get all kinds of runtime errors so they are not interchangable despite bearing the same classnames and almost the same interface. This is a questionable solution on the library vendors' behalf but in my case I either take it or leave.
I would like to work with both libraries in one project, allowing the user to specify which model is connected. It should be assumed that the end-user can never have both versions on their machine.
I've managed to add interops for both libraries to the project in Visual Studio by renaming them but I also need to somehow differentiate which one is used, so I've assigned aliases to them. The first interop I've assigned an alias to doesn't cause any problems, but the second one aliased always creates compiler errors.
The extern alias 'xxx' was not specified in a /reference option
No matter what I do it refuses to recognize the second alias. Furthermore, if I press the view object in browser button on the second interop it points to the information of the first one which suggests to me that Visual Studio in it's infinite wisdom ignores the second interop completely.
In past a coleague solved this by disassembling one of the interops and modifying the namespace but I'd like to know if there are any better solutions.
Thank you for your time.
visual-studio .net-4.0 com-interop
New contributor
add a comment |
I have two versions of a third-party com library. They are identical in namespace, but one is built to work with devices of X model, while the other works with Y model hardware. If I use the wrong library I get all kinds of runtime errors so they are not interchangable despite bearing the same classnames and almost the same interface. This is a questionable solution on the library vendors' behalf but in my case I either take it or leave.
I would like to work with both libraries in one project, allowing the user to specify which model is connected. It should be assumed that the end-user can never have both versions on their machine.
I've managed to add interops for both libraries to the project in Visual Studio by renaming them but I also need to somehow differentiate which one is used, so I've assigned aliases to them. The first interop I've assigned an alias to doesn't cause any problems, but the second one aliased always creates compiler errors.
The extern alias 'xxx' was not specified in a /reference option
No matter what I do it refuses to recognize the second alias. Furthermore, if I press the view object in browser button on the second interop it points to the information of the first one which suggests to me that Visual Studio in it's infinite wisdom ignores the second interop completely.
In past a coleague solved this by disassembling one of the interops and modifying the namespace but I'd like to know if there are any better solutions.
Thank you for your time.
visual-studio .net-4.0 com-interop
New contributor
add a comment |
I have two versions of a third-party com library. They are identical in namespace, but one is built to work with devices of X model, while the other works with Y model hardware. If I use the wrong library I get all kinds of runtime errors so they are not interchangable despite bearing the same classnames and almost the same interface. This is a questionable solution on the library vendors' behalf but in my case I either take it or leave.
I would like to work with both libraries in one project, allowing the user to specify which model is connected. It should be assumed that the end-user can never have both versions on their machine.
I've managed to add interops for both libraries to the project in Visual Studio by renaming them but I also need to somehow differentiate which one is used, so I've assigned aliases to them. The first interop I've assigned an alias to doesn't cause any problems, but the second one aliased always creates compiler errors.
The extern alias 'xxx' was not specified in a /reference option
No matter what I do it refuses to recognize the second alias. Furthermore, if I press the view object in browser button on the second interop it points to the information of the first one which suggests to me that Visual Studio in it's infinite wisdom ignores the second interop completely.
In past a coleague solved this by disassembling one of the interops and modifying the namespace but I'd like to know if there are any better solutions.
Thank you for your time.
visual-studio .net-4.0 com-interop
New contributor
I have two versions of a third-party com library. They are identical in namespace, but one is built to work with devices of X model, while the other works with Y model hardware. If I use the wrong library I get all kinds of runtime errors so they are not interchangable despite bearing the same classnames and almost the same interface. This is a questionable solution on the library vendors' behalf but in my case I either take it or leave.
I would like to work with both libraries in one project, allowing the user to specify which model is connected. It should be assumed that the end-user can never have both versions on their machine.
I've managed to add interops for both libraries to the project in Visual Studio by renaming them but I also need to somehow differentiate which one is used, so I've assigned aliases to them. The first interop I've assigned an alias to doesn't cause any problems, but the second one aliased always creates compiler errors.
The extern alias 'xxx' was not specified in a /reference option
No matter what I do it refuses to recognize the second alias. Furthermore, if I press the view object in browser button on the second interop it points to the information of the first one which suggests to me that Visual Studio in it's infinite wisdom ignores the second interop completely.
In past a coleague solved this by disassembling one of the interops and modifying the namespace but I'd like to know if there are any better solutions.
Thank you for your time.
visual-studio .net-4.0 com-interop
visual-studio .net-4.0 com-interop
New contributor
New contributor
New contributor
asked yesterday
CodeMolester69
1
1
New contributor
New contributor
add a comment |
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
CodeMolester69 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53944289%2ftwo-interops-of-same-name-in-one-project%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
CodeMolester69 is a new contributor. Be nice, and check out our Code of Conduct.
CodeMolester69 is a new contributor. Be nice, and check out our Code of Conduct.
CodeMolester69 is a new contributor. Be nice, and check out our Code of Conduct.
CodeMolester69 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53944289%2ftwo-interops-of-same-name-in-one-project%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown