Greetings,
Could anyone help me in this please?
I am trying to use C# code to open OpenDesignFile using “Bentely Microstation Connect Edition”.
I am using the below code:
******************************************* MicroStationDGN.Application microStationApplication;
MicroStationDGN.ApplicationObjectConnector applicationObjectConnector = new MicroStationDGN.ApplicationObjectConnector();
microStationApplication = applicationObjectConnector.Application; microStationApplication.OpenDesignFile(@"Path", false); microStationApplication.Visible = true;*******************************************
Every time I build this code I receive the below exception:
---------------------------
---------------------------System.Runtime.InteropServices.COMException (0x80010001): Creating an instance of the COM component with CLSID {E95E943A-545B-46A5-B2A8-0B590262EEC3} from the IClassFactory failed due to the following error: 80010001 Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED)).
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at TestNew10Microstation.Form1.button1_Click(Object sender, EventArgs e) in ---------------------------OK ---------------------------
Please help;;
BTW, I am using "Bentley MicroStation 10.x Object Library 10.1" and VS 2017
Hi Khalid,
at first, I recommend to move your post to MicroStation Programming forum. This is general Developers and Programming forum, focusing primarily product without specialized programming forums available. To move existing post to another forum, use More > Move tool available under your original post.
Also, use Insert > Insert code tool for sharing code (even one line only), so it will be not displayed as a plain text, which is ugly and hard to read.
Khalid Alshehri said:I am using "Bentley MicroStation 10.x Object Library 10.1"
Why you do not use Interop API available in Bentley.Interop.MicroStationDGN.dll assembly?
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Sorry for the late reply, I actually did used the way used in the Bentley.Interop.MicroStationDGN.dll to open design file but I keep getting server execution failed exception
Khalid Alshehri said:I actually did used the way used in the Bentley.Interop.MicroStationDGN.dll to open design file but I keep getting server execution failed exception
Sorry, but I do not understand :-(
Do you use (reference) MicroStation Object Library, so you access COM interface directly, or you reference MicroStation Interop (using prepared COM/Interop API)?
Regards,
Khalid Alshehri said:I am trying to use C# code
MicroStation CONNECT is a 64-bit app. Have you configured Viz Studio to create a 64-bit app?
Regards, Jon Summers LA Solutions
Hi
Thanks for your reply
In the visual studio project, I referenced
Bentley.Interop.MicroStationDGN.dll
Which is available in the assemblies folder under the application folder.
Regards;
Yes I changed it in the solution configuration Manager to be x64 and the same for project platform but still getting the server excution failed exception when trying to create instance
Khalid Alshehri said:I am trying to use C# code to open OpenDesignFile using “Bentely Microstation Connect Edition”
Do you have any other version of MicroStation installed on your computer?
Show us a screenshot of your Viz Studio References for your project, focussing on the Bentley assemblies that you include.
To explain more, I actually used two different methods or piece of code to open design file
1- first method I referenced the Bentley.Interop.MicroStationDGN.dll which is available in the assemblies folder under the application folder
Then I got the system.type by using the
type.GetTypeFromProgID(CLSID)
And Activator.createinstance(type)
2- second method is the one specified in the main question above using "Bentley Microstation 10.x object library " named MicrostationDGN
For the first method (1) I faced the server execution failed exception
And for the second method (2) I faced
"IClassFactory failed due to the following error: 80010001 Call was rejected by callee".
Thanks for your reply and help.
I really appreciate it
at first, please use Insert > Insert code when you want to share a code snippet (even one line). It's not easy to read the text you posted, when there is no difference between text and code.
Khalid Alshehri said:1- first method I referenced the Bentley.Interop.MicroStationDGN.dll
Why to do it in so complicated way? What is the reason to use Activator?