OS. Start Your C# Project
This quick set of steps demonstrates how to set up your workspace for a C# project.
-
In the Visual Studio start window, click Create a new
project.
The Create a new project window opens.
-
Filter the project templates using the following:
- Type console in the search field.
- Select C# from the Language drop-down list.
- Select Windows from the Platform drop-down list.
-
Select the Console App (.NET Framework) from the results
and then click Next.
The Configure your new project window opens.
- Type OpenSTAAD Demo in the Project Name field.
-
Click Create.
Visual Studio opens your new project, which includes default
Hello World
code. -
Add necessary dependencies to the manifest file:
-
Right-click on your project's name and then select New Item > Application Manifest File.
The template for the app.manifest file opens.
-
Add the following elements within the
<assembly>
element:<comInterfaceExternalProxyStub name="IOSMemberSteelDgnParams" iid="{F40BDCDA-B3DE-495C-B84F-790F4456137F}" tlbid="{EDA9FA7F-EFC9-4264-9513-39CF6E72604D}" proxyStubClsid32="{00020420-0000-0000-C000-000000000046}"></comInterfaceExternalProxyStub> <comInterfaceExternalProxyStub name="IOpenSTAADUI" iid="{3F5B8055-31C6-446E-8BED-FEE43E09D4CC}" tlbid="{EDA9FA7F-EFC9-4264-9513-39CF6E72604D}" proxyStubClsid32="{00020420-0000-0000-C000-000000000046}"></comInterfaceExternalProxyStub> <comInterfaceExternalProxyStub name="IOSGeometryUI" iid="{C052FED9-A2D6-42E3-A271-2C6FB8461711}" tlbid="{EDA9FA7F-EFC9-4264-9513-39CF6E72604D}" proxyStubClsid32="{00020420-0000-0000-C000-000000000046}"></comInterfaceExternalProxyStub> <comInterfaceExternalProxyStub name="IStaadProWindow" iid="{9EF2FF8C-E574-4A04-9462-2E4500C8EADB}" tlbid="{EDA9FA7F-EFC9-4264-9513-39CF6E72604D}" proxyStubClsid32="{00020420-0000-0000-C000-000000000046}"></comInterfaceExternalProxyStub> <comInterfaceExternalProxyStub name="IOSViewUI" iid="{87B1975B-6031-487E-A0F9-FB8F69FA24E6}" tlbid="{EDA9FA7F-EFC9-4264-9513-39CF6E72604D}" proxyStubClsid32="{00020420-0000-0000-C000-000000000046}"></comInterfaceExternalProxyStub> <comInterfaceExternalProxyStub name="IOSOutputUI" iid="{824F1FC0-DC86-4CC4-A4C6-83C77D7B0496}" tlbid="{EDA9FA7F-EFC9-4264-9513-39CF6E72604D}" proxyStubClsid32="{00020420-0000-0000-C000-000000000046}"></comInterfaceExternalProxyStub> <comInterfaceExternalProxyStub name="IOSPropertyUI" iid="{F919EF7D-E1DD-48CB-B3C3-B3CAE9E3B5AB}" tlbid="{EDA9FA7F-EFC9-4264-9513-39CF6E72604D}" proxyStubClsid32="{00020420-0000-0000-C000-000000000046}"></comInterfaceExternalProxyStub> <comInterfaceExternalProxyStub name="IOSLoadUI" iid="{DAA37D16-821F-4137-88EB-DA4EB7650E90}" tlbid="{EDA9FA7F-EFC9-4264-9513-39CF6E72604D}" proxyStubClsid32="{00020420-0000-0000-C000-000000000046}"></comInterfaceExternalProxyStub> <comInterfaceExternalProxyStub name="IOSTableUI" iid="{CF1A7B89-A007-4844-A098-CBABAEBEF304}" tlbid="{EDA9FA7F-EFC9-4264-9513-39CF6E72604D}" proxyStubClsid32="{00020420-0000-0000-C000-000000000046}"></comInterfaceExternalProxyStub> <comInterfaceExternalProxyStub name="IOSSupportUI" iid="{B076EC62-9A33-4E1C-B38C-3E45090B8531}" tlbid="{EDA9FA7F-EFC9-4264-9513-39CF6E72604D}" proxyStubClsid32="{00020420-0000-0000-C000-000000000046}"></comInterfaceExternalProxyStub> <comInterfaceExternalProxyStub name="IOSCommandsUI" iid="{6B994A7C-122C-4828-B42B-1B0CADF91F9D}" tlbid="{EDA9FA7F-EFC9-4264-9513-39CF6E72604D}" proxyStubClsid32="{00020420-0000-0000-C000-000000000046}"></comInterfaceExternalProxyStub> <comInterfaceExternalProxyStub name="IOSDesignUI" iid="{ED218322-40EE-411C-8552-209DB2C4F32B}" tlbid="{EDA9FA7F-EFC9-4264-9513-39CF6E72604D}" proxyStubClsid32="{00020420-0000-0000-C000-000000000046}"></comInterfaceExternalProxyStub>
- Save and close the manifest file.
-
Right-click on your project's name and then select New Item > Application Manifest File.
-
Add the staadpro.dll dependency to the project file:
This adds OpenSTAAD as a COM file reference.
-
Open the project's .csproj file.
This file is located at the rood directory of the project.
-
Add the following element to the start of the
ItemGroup
element:<COMFileReference Include="C:\Program Files\Bentley\Engineering\STAAD.Pro 2023\STAAD\StaadPro.dll"> <EmbedInteropTypes>True</EmbedInteropTypes> </COMFileReference>
- Save and close the project file.
-
Open the project's .csproj file.
-
Add the manifest to the build:
- In the Solutions Explorer, right-click on the project and then select Properties from the pop-up menu.
- Select the Build Events tabs.
-
Add the following to the post-build event command line:
copy $(ProjectDir)app.manifest $(TargetDir)\$(AssemblyName).exe.manifest