cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Call C# Object from MathCad?

bobnew-disabled
1-Visitor

Call C# Object from MathCad?

Hi,

I am working with MathCad 13 and Visual Studio 2005. I am trying to create a C# object, make it into a COM callable object, and then use that object from within MathCad.

I have played with COM objects created in VB6 and have been able to use them with in VB Script within MathCad.

For example, this code works as part of a button object in a MathCad worksheet.

Sub PushBtnEvent_Exec(Inputs,Outputs)
Dim b
MsgBox "Exec"
Set b = GetObject( "", "VerySimpObject.MyClass" )
MsgBox "after create object " & b.Name
End Sub

In the above case, 'VerySimpObject' is a VB6 ActiveX DLL. When it is executed, there are two MsgBoxes as expected.

When I try to do this with a simple C# object, I get an error on the GetObject call. The first MsgBox displays as expected, but then an error is reported:

(null)
Line:18 Error:0
(null)

Is it possible to invoke a .Net object from MathCad 13?

Thanks,

Bob

3 REPLIES 3

I'm amazed you haven't received any responses. I have been trying to extend Mathcad with VS2005 and now VB6 with great difficulty. Today I figured out I might just create my own object with VB6 and just found your note. Very interesting. All I am trying to do is record a sound into an array! That should actually be provided but isn't. I initially thought it would be simple. Not so for me, a beginner in sound. How did you figure out about VB6 active X dll's? All the literature out there keeps saying VB6 can't make DLL's. I guess they forgot the ActiveX ones??
RichardJ
19-Tanzanite
(To:wjhorsley)

I was finally able to do this. I created
a C# object in Visual Studio 2005 and accessed
it through VB script behind a control on a
MathCad page.

The hints that I needed for this came from a
page at gsraj.tripod.com.

Essentially, in order to do this, the C# assembly
needs to be accessed as an out-of-process server
instead of in-process.

Attached is a PDF that describes the steps I
used to create and use a C# object from MathCad.

Bob

Announcements

Top Tags