Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Call C# from PB9

26 views
Skip to first unread message

charliesherbow

unread,
Jun 16, 2008, 12:59:20 PM6/16/08
to
We are attempting to use some functions written in Visual
Studio 2005 C# by our company. We are trying to crawl before
we walk.

We can't figure out how to do the call or how to write the
function. We are already using functions from the windows
API, but we can't figure out how to set up the VS2005
functions. A trivial example (which we can not get to work
is)
C# Code:
using System;
using System.Runtime.InteropServices;

namespace Utility
{
public class ReadExcel
{
public string of_read_excel(string FileNameWithPath)
{
return "i am here!";
}
}
}

We have to be missing something like a particular attribute
setting in C#. We have tried putting the resulting dll in
many different places (including with the pb source code)
and it still fails.

In PB the set up is like:
This is the external function call:
FUNCTION string of_read_excel(string as_file_name) LIBRARY
"Utility.dll"

This is my code trying to use the external function call:
string ls_return, ls_file_name

ls_file_name = "c:\chs.xls"
ls_return = of_read_excel(ls_file_name)

mle_return.text += ls_return

Does someone know what we are doint wrong in c#?

Thanks
Charlie

Bruce Armstrong [TeamSybase]

unread,
Jun 16, 2008, 1:28:57 PM6/16/08
to

C# doesn't create a DLL that can be called via standard Windows API type
calls. It creates a managed assembly. What you need to do is make sure the
assembly is marked as COM-Visible, run regasm on the generated assembly to
create the COM entries for it, and then call it via COM.

http://msdn.microsoft.com/en-us/library/f07c8z1c.aspx

http://pbdj.sys-con.com/read/420516.htm

<Charlie Sherbow> wrote in message
news:48569be8.6bf...@sybase.com...

0 new messages