
Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
> > Are you indicating that I should recompile the DLL in VB.NET with Public AND
> > Shared properties?
>
> Well, it's probably simpler to create an instance of the class and call
> the method that way.
Simpler, but not necessarily more correct. It really depends on
whether the eventual method needs to access instance data or not (I
assume the OP currently has a "Hello World" style function).
To the op:
If you need an instance, you would write something like:
TestDLL.TestClass testObject = new TestDLL.TestClass();
i = testObject.ADD(1,2);
if you make the function Shared (which in C# is spelt "static"), you
write
i = TestDLL.TestClass.ADD(1,2);
in both examples, you can get rid of the "TestDLL." if you put:
using TestDLL;
at the top of the file (I wouldn't though - I had the way that lots of
"using" statements make it impossible to work out where the classes
are coming from).
I would also recommend using FxCop to keep your code clean. Unless
you switch it off, it will suggest using TestDll as the name of the
namespace, and Add as the name of the function.
Jerry West - 14 Mar 2008 17:59 GMT
Thanks for that --and the proper syntax. Just what I was needing given my
lack of C# knowledge.
Just one final item. I wanted to actually test the call. However, I need to
declare i as shown in the example:
i = TestDLL.TestClass.ADD(1,2);
I did so like:
int i;
But I'm still, apparently, missing something. VS flags i in this statement:
i = TestDLL.TestClass.ADD(1,2);
It indicates "A new expression requires (), [], or {} after type". I tried
all three but each time resulted in more errors, i.e.:
i() = TestDLL.TestClass.ADD(1,2);
i[] = TestDLL.TestClass.ADD(1,2);
i{} = TestDLL.TestClass.ADD(1,2);
I tried it with my declaration as well. What am I missing?
JW
>> > Are you indicating that I should recompile the DLL in VB.NET with
>> > Public AND
[quoted text clipped - 27 lines]
> you switch it off, it will suggest using TestDll as the name of the
> namespace, and Add as the name of the function.
Jon Skeet [C# MVP] - 14 Mar 2008 20:27 GMT
> Thanks for that --and the proper syntax. Just what I was needing given my
> lack of C# knowledge.
[quoted text clipped - 20 lines]
>
> I tried it with my declaration as well. What am I missing?
Well, we've got no idea what the context of your statement is.
Could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Jerry West - 14 Mar 2008 21:19 GMT
{
int x;
InitializeComponent();
TestDLL.Class1 testObject = new TestDLL.Class1
x = testObject.ADD(1,2);
}
The IDE warns me --by placing a line underneath the "x" var where I am
making the assignment-- it states:
"A new expression requires (), [], or {} after type".
Of course, I cannot setup thru the code due to this error. I'm sure its
something simple but being new to C# and finding examples on the Net showing
what I already am doing I just don't see the problem.
JW
>> Thanks for that --and the proper syntax. Just what I was needing given my
>> lack of C# knowledge.
[quoted text clipped - 31 lines]
> See http://www.pobox.com/~skeet/csharp/complete.html for details of
> what I mean by that.
Jon Skeet [C# MVP] - 14 Mar 2008 21:35 GMT
> {
> int x;
[quoted text clipped - 7 lines]
>
> "A new expression requires (), [], or {} after type".
That's because you haven't got () or a semi-colon on the line above.
It should be:
TestDLL.Class1 testObject = new TestDLL.Class1();

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Jerry West - 14 Mar 2008 21:49 GMT
Thanks!
JW
>> {
>> int x;
[quoted text clipped - 13 lines]
>
> TestDLL.Class1 testObject = new TestDLL.Class1();