using c# class

  • Thread starter Thread starter mgarner1980
  • Start date Start date
M

mgarner1980

I have a class writen in c# that I want to use in my VB.NETCF project. I
can't seem to get it to work. What is the process for this?
 
mgarner1980 said:
I have a class writen in c# that I want to use in my VB.NETCF project. I
can't seem to get it to work. What is the process for this?

Either add the compiled DLL for the C# class as a reference to your VB.NET
project, or add the C# class as a separate project in your Solution. You
can't have two different languages in the same project.
 
I've added the project to the solution. But I can't seem to be able to "get"
to any of the classes in the c# project. I'm obviously missing something
fundamental here. Any ideas?
 
Have you added reference to this project? In the solution explorer
select "References", Right Click, Add Reference, select tab Projects,
choose your C# project in this list.

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
 
yes I did. I have 2 projects for testing

vbproject and csharpproject

vbproject has one form
csharpproject has one public class......class1

on the vbproject form I'm trying to instantiate a instance of csharp.class1.

even though I've added a referance to csharpproject.......I can't seem to
"see" class1.

Obviously I'm still missing something fundamental. Up to now I've only had
single project solutions and only in vb.net.

Thanks
Mark
 
Can you use the class if you fully qualify it i.e. csharpproject.class1?

The last step is to add an Imports at the top of your file e.g. Imports
csharpproject

Cheers
Daniel
 
Ok, some more questions.

1. Do you have both projects in one solution?

Solution Name
|
\- Project VB
|
\- Project CS (contains class "ClassNamspace.Class1")


2. Have you added rereference to Project VB as I described in my
previous post?

3. Does your VB code look like:

Dim t As ClassNamespace.Class1 = New ClassNamespace.Class1


Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
 
csharpproject and vbproject respectively...I think.... that's what the
default namespace shows in the project properties.
 
I've tried everytying suggested...and the answer is a resounding no. I must
be way of base here.

I tried to zip up the solution and attach it...but I keep getting a file too
big error.

Here's what I did in a nutshell
1) created new vb project (smartdevice )
2)right clicked on solution and selected add project and select c#
smartdevice application.
3) tried to add reference to the c# project and got error tht only dll could
be referenced.
4) deleted form1 from c# project and changed project to class library.
5) successfully added reference to c# project
6) tried dim t as new csharpproject.class1 = new csharpproject.class1
7) got error that class1 csharpprojectg.class1 doesn't exist.
 
Delete/remove the c# project and add it again this time choosing Class
Library (not application) *still* under the Smart Device wizard.

After adding the reference make sure it worked by looking under the
References node in Solution Explorer

To make sure you've got the correct namespaceName.className, use View->Class
View and check there what are the names.

Try again

Cheers
Daniel
 
no luck....I must be an idiot!
Daniel Moth said:
Delete/remove the c# project and add it again this time choosing Class
Library (not application) *still* under the Smart Device wizard.

After adding the reference make sure it worked by looking under the
References node in Solution Explorer

To make sure you've got the correct namespaceName.className, use View->Class
View and check there what are the names.

Try again

Cheers
Daniel
 
Back
Top