COM class cannot be found when running .net code from Matlab












0














I'm using c# do build a few libraries which we then use from within Matlab 64bit. The c# library is compiled to 64bit so that we can use it from Matlab. The c# library uses an interop to call a COM component which is legacy 32bit code. When running the tests in c# everything works but if I use the library from Matlab I get the following error:



Message: Unable to cast COM object of type '...' to interface type '...'. This operation failed because the
QueryInterface call on the COM component for the interface with IID '{...}' failed due to the following
error: Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
Source: mscorlib



To me it looks like the runtime is looking for the 64bit of the COM class but I don't understand why but afaik visual studio 2017 is still 32 bit thats why it is picking the right COM. Any help is welcome.



UPDATE



I tried to run the code using a 64bit test loaded and I get the same error, so it was running from VS because it is 32bit. Having identified that, is there a way to force a 64bit execution context to call 32bit COM components?



Thanks










share|improve this question
























  • mathworks.com/matlabcentral/answers/…
    – kunif
    Nov 20 at 10:35










  • @kunif what made you think that I know how to read japanese? And Matlab i know how to call COM components from Matlab, what I'm struggling with is being able to use 32bit COMs from c# which is then used by Matlab. Matlab only uses .net code. Thanks a lot for your help anyway.
    – MeTitus
    Nov 20 at 10:42












  • alternatively, techtalk.gfi.com/32bit-object-64bit-environment
    – kunif
    Nov 20 at 10:56










  • @kunif I saw that one, but it's a hack and prone to so many issues, even a windows update can break that. I decided to build a desktop daemon as a wrapper to all those legacy COMs. Thanks
    – MeTitus
    Nov 20 at 11:12
















0














I'm using c# do build a few libraries which we then use from within Matlab 64bit. The c# library is compiled to 64bit so that we can use it from Matlab. The c# library uses an interop to call a COM component which is legacy 32bit code. When running the tests in c# everything works but if I use the library from Matlab I get the following error:



Message: Unable to cast COM object of type '...' to interface type '...'. This operation failed because the
QueryInterface call on the COM component for the interface with IID '{...}' failed due to the following
error: Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
Source: mscorlib



To me it looks like the runtime is looking for the 64bit of the COM class but I don't understand why but afaik visual studio 2017 is still 32 bit thats why it is picking the right COM. Any help is welcome.



UPDATE



I tried to run the code using a 64bit test loaded and I get the same error, so it was running from VS because it is 32bit. Having identified that, is there a way to force a 64bit execution context to call 32bit COM components?



Thanks










share|improve this question
























  • mathworks.com/matlabcentral/answers/…
    – kunif
    Nov 20 at 10:35










  • @kunif what made you think that I know how to read japanese? And Matlab i know how to call COM components from Matlab, what I'm struggling with is being able to use 32bit COMs from c# which is then used by Matlab. Matlab only uses .net code. Thanks a lot for your help anyway.
    – MeTitus
    Nov 20 at 10:42












  • alternatively, techtalk.gfi.com/32bit-object-64bit-environment
    – kunif
    Nov 20 at 10:56










  • @kunif I saw that one, but it's a hack and prone to so many issues, even a windows update can break that. I decided to build a desktop daemon as a wrapper to all those legacy COMs. Thanks
    – MeTitus
    Nov 20 at 11:12














0












0








0







I'm using c# do build a few libraries which we then use from within Matlab 64bit. The c# library is compiled to 64bit so that we can use it from Matlab. The c# library uses an interop to call a COM component which is legacy 32bit code. When running the tests in c# everything works but if I use the library from Matlab I get the following error:



Message: Unable to cast COM object of type '...' to interface type '...'. This operation failed because the
QueryInterface call on the COM component for the interface with IID '{...}' failed due to the following
error: Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
Source: mscorlib



To me it looks like the runtime is looking for the 64bit of the COM class but I don't understand why but afaik visual studio 2017 is still 32 bit thats why it is picking the right COM. Any help is welcome.



UPDATE



I tried to run the code using a 64bit test loaded and I get the same error, so it was running from VS because it is 32bit. Having identified that, is there a way to force a 64bit execution context to call 32bit COM components?



Thanks










share|improve this question















I'm using c# do build a few libraries which we then use from within Matlab 64bit. The c# library is compiled to 64bit so that we can use it from Matlab. The c# library uses an interop to call a COM component which is legacy 32bit code. When running the tests in c# everything works but if I use the library from Matlab I get the following error:



Message: Unable to cast COM object of type '...' to interface type '...'. This operation failed because the
QueryInterface call on the COM component for the interface with IID '{...}' failed due to the following
error: Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
Source: mscorlib



To me it looks like the runtime is looking for the 64bit of the COM class but I don't understand why but afaik visual studio 2017 is still 32 bit thats why it is picking the right COM. Any help is welcome.



UPDATE



I tried to run the code using a 64bit test loaded and I get the same error, so it was running from VS because it is 32bit. Having identified that, is there a way to force a 64bit execution context to call 32bit COM components?



Thanks







c# .net matlab com






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 10:12

























asked Nov 20 at 9:52









MeTitus

2,6651338




2,6651338












  • mathworks.com/matlabcentral/answers/…
    – kunif
    Nov 20 at 10:35










  • @kunif what made you think that I know how to read japanese? And Matlab i know how to call COM components from Matlab, what I'm struggling with is being able to use 32bit COMs from c# which is then used by Matlab. Matlab only uses .net code. Thanks a lot for your help anyway.
    – MeTitus
    Nov 20 at 10:42












  • alternatively, techtalk.gfi.com/32bit-object-64bit-environment
    – kunif
    Nov 20 at 10:56










  • @kunif I saw that one, but it's a hack and prone to so many issues, even a windows update can break that. I decided to build a desktop daemon as a wrapper to all those legacy COMs. Thanks
    – MeTitus
    Nov 20 at 11:12


















  • mathworks.com/matlabcentral/answers/…
    – kunif
    Nov 20 at 10:35










  • @kunif what made you think that I know how to read japanese? And Matlab i know how to call COM components from Matlab, what I'm struggling with is being able to use 32bit COMs from c# which is then used by Matlab. Matlab only uses .net code. Thanks a lot for your help anyway.
    – MeTitus
    Nov 20 at 10:42












  • alternatively, techtalk.gfi.com/32bit-object-64bit-environment
    – kunif
    Nov 20 at 10:56










  • @kunif I saw that one, but it's a hack and prone to so many issues, even a windows update can break that. I decided to build a desktop daemon as a wrapper to all those legacy COMs. Thanks
    – MeTitus
    Nov 20 at 11:12
















mathworks.com/matlabcentral/answers/…
– kunif
Nov 20 at 10:35




mathworks.com/matlabcentral/answers/…
– kunif
Nov 20 at 10:35












@kunif what made you think that I know how to read japanese? And Matlab i know how to call COM components from Matlab, what I'm struggling with is being able to use 32bit COMs from c# which is then used by Matlab. Matlab only uses .net code. Thanks a lot for your help anyway.
– MeTitus
Nov 20 at 10:42






@kunif what made you think that I know how to read japanese? And Matlab i know how to call COM components from Matlab, what I'm struggling with is being able to use 32bit COMs from c# which is then used by Matlab. Matlab only uses .net code. Thanks a lot for your help anyway.
– MeTitus
Nov 20 at 10:42














alternatively, techtalk.gfi.com/32bit-object-64bit-environment
– kunif
Nov 20 at 10:56




alternatively, techtalk.gfi.com/32bit-object-64bit-environment
– kunif
Nov 20 at 10:56












@kunif I saw that one, but it's a hack and prone to so many issues, even a windows update can break that. I decided to build a desktop daemon as a wrapper to all those legacy COMs. Thanks
– MeTitus
Nov 20 at 11:12




@kunif I saw that one, but it's a hack and prone to so many issues, even a windows update can break that. I decided to build a desktop daemon as a wrapper to all those legacy COMs. Thanks
– MeTitus
Nov 20 at 11:12

















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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53390326%2fcom-class-cannot-be-found-when-running-net-code-from-matlab%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53390326%2fcom-class-cannot-be-found-when-running-net-code-from-matlab%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin