473,383 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Find a class in a solution with mulitpile projects

Hi all,

I have a class in project A.
At the same solution, I have another project - named project B.

I want to write a piece of code in that class from project B that finds the
class in project A. How can I do that?

I have a code to do that, if the class is in the same project (by using
Application.ProductName, but even if I chaned it to the second project name,
its didn't work), and I've referenced it because I have some froms that I
inherited from project A..
:
Code:
Function GetFormByName(ByVal stFileName As String) As Form
Dim tFormType As Type = Type.GetType(stFileName, False)
If tFormType Is Nothing Then
Dim Fullname As String = Application.ProductName & "." &
stFileName
tFormType = Type.GetType(Fullname, False, True)
If tFormType Is Nothing Then
Throw New Exception(stFileName + " could not be found")
End If
End If
Return CType(Activator.CreateInstance(tFormType), Form)
End Function

Thanks
Jun 27 '08 #1
5 1327
Ohad

Simple use one the reference box which you can find in the Solution explorer
at top of a project of in the Project menu.

You can directly point to the other project in your solution, or to the DLL
that it has created.
Be aware that you have to in the Build options which projects and in what
other they have to be build.

As well, don't forget to set the Import directive to your namespace.
Otherwise you have to set that everytime in your code.

Cor

"Ohad weiss" <oh***@netvision.net.ilschreef in bericht
news:eu**************@TK2MSFTNGP03.phx.gbl...
Hi all,

I have a class in project A.
At the same solution, I have another project - named project B.

I want to write a piece of code in that class from project B that finds
the class in project A. How can I do that?

I have a code to do that, if the class is in the same project (by using
Application.ProductName, but even if I chaned it to the second project
name, its didn't work), and I've referenced it because I have some froms
that I inherited from project A..
:
Code:
Function GetFormByName(ByVal stFileName As String) As Form
Dim tFormType As Type = Type.GetType(stFileName, False)
If tFormType Is Nothing Then
Dim Fullname As String = Application.ProductName & "." &
stFileName
tFormType = Type.GetType(Fullname, False, True)
If tFormType Is Nothing Then
Throw New Exception(stFileName + " could not be found")
End If
End If
Return CType(Activator.CreateInstance(tFormType), Form)
End Function

Thanks

Jun 27 '08 #2
Thanks for the reply Cor,
But the project I'm trying to find its class (Project A) is of type Exe and
not Dll.
Therefore, I can't add a reference to it.

Ohad

"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:4B**********************************@microsof t.com...
Ohad

Simple use one the reference box which you can find in the Solution
explorer at top of a project of in the Project menu.

You can directly point to the other project in your solution, or to the
DLL that it has created.
Be aware that you have to in the Build options which projects and in what
other they have to be build.

As well, don't forget to set the Import directive to your namespace.
Otherwise you have to set that everytime in your code.

Cor

"Ohad weiss" <oh***@netvision.net.ilschreef in bericht
news:eu**************@TK2MSFTNGP03.phx.gbl...
>Hi all,

I have a class in project A.
At the same solution, I have another project - named project B.

I want to write a piece of code in that class from project B that finds
the class in project A. How can I do that?

I have a code to do that, if the class is in the same project (by using
Application.ProductName, but even if I chaned it to the second project
name, its didn't work), and I've referenced it because I have some froms
that I inherited from project A..
:
Code:
Function GetFormByName(ByVal stFileName As String) As Form
Dim tFormType As Type = Type.GetType(stFileName, False)
If tFormType Is Nothing Then
Dim Fullname As String = Application.ProductName & "." &
stFileName
tFormType = Type.GetType(Fullname, False, True)
If tFormType Is Nothing Then
Throw New Exception(stFileName + " could not be found")
End If
End If
Return CType(Activator.CreateInstance(tFormType), Form)
End Function

Thanks


Jun 27 '08 #3
Ohad

Then why not simple make a DLL from it?

Cor

"Ohad weiss" <oh***@netvision.net.ilschreef in bericht
news:eY**************@TK2MSFTNGP03.phx.gbl...
Thanks for the reply Cor,
But the project I'm trying to find its class (Project A) is of type Exe
and not Dll.
Therefore, I can't add a reference to it.

Ohad

"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:4B**********************************@microsof t.com...
>Ohad

Simple use one the reference box which you can find in the Solution
explorer at top of a project of in the Project menu.

You can directly point to the other project in your solution, or to the
DLL that it has created.
Be aware that you have to in the Build options which projects and in what
other they have to be build.

As well, don't forget to set the Import directive to your namespace.
Otherwise you have to set that everytime in your code.

Cor

"Ohad weiss" <oh***@netvision.net.ilschreef in bericht
news:eu**************@TK2MSFTNGP03.phx.gbl...
>>Hi all,

I have a class in project A.
At the same solution, I have another project - named project B.

I want to write a piece of code in that class from project B that finds
the class in project A. How can I do that?

I have a code to do that, if the class is in the same project (by using
Application.ProductName, but even if I chaned it to the second project
name, its didn't work), and I've referenced it because I have some froms
that I inherited from project A..
:
Code:
Function GetFormByName(ByVal stFileName As String) As Form
Dim tFormType As Type = Type.GetType(stFileName, False)
If tFormType Is Nothing Then
Dim Fullname As String = Application.ProductName & "." &
stFileName
tFormType = Type.GetType(Fullname, False, True)
If tFormType Is Nothing Then
Throw New Exception(stFileName + " could not be found")
End If
End If
Return CType(Activator.CreateInstance(tFormType), Form)
End Function

Thanks


Jun 27 '08 #4
Because its another exe project.
I'll try to explain:
I have a project that its results is dll. It contains that main app form(mdi
paren), login form, and general form. This project result a dll file.
In the same solution I have another 2 projects that their result is exe file
(each on of them). tese two projects has classes that inherit from the
general form in the project that created the dll.
In one of my classes in the exe projects, I need to scan a class in the
second exe project and retrieve the controls on it. This is why I cant use
it as a dll.

Is there any way to set reference to an exe project?

If I change the second param in the function tFormType =
Type.GetType(Fullname, False, True) to true, I get an exception about the
assembly:
Could not load type X from assembly Y, version=1.0...., culture=neutral,
publickeytoken=null.
X- the path and the fulename I'm trying to retrive (which is in project X)
Y - the name of project Y from which I'm trying to call the form in the
second project
Is there any way to set reference to an exe project? Or maybe you can
explain me how to set another assembly to the project

I can send the code if needed.

Thanks Ohad

"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:19**********************************@microsof t.com...
Ohad

Then why not simple make a DLL from it?

Cor

"Ohad weiss" <oh***@netvision.net.ilschreef in bericht
news:eY**************@TK2MSFTNGP03.phx.gbl...
>Thanks for the reply Cor,
But the project I'm trying to find its class (Project A) is of type Exe
and not Dll.
Therefore, I can't add a reference to it.

Ohad

"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:4B**********************************@microso ft.com...
>>Ohad

Simple use one the reference box which you can find in the Solution
explorer at top of a project of in the Project menu.

You can directly point to the other project in your solution, or to the
DLL that it has created.
Be aware that you have to in the Build options which projects and in
what other they have to be build.

As well, don't forget to set the Import directive to your namespace.
Otherwise you have to set that everytime in your code.

Cor

"Ohad weiss" <oh***@netvision.net.ilschreef in bericht
news:eu**************@TK2MSFTNGP03.phx.gbl...
Hi all,

I have a class in project A.
At the same solution, I have another project - named project B.

I want to write a piece of code in that class from project B that finds
the class in project A. How can I do that?

I have a code to do that, if the class is in the same project (by using
Application.ProductName, but even if I chaned it to the second project
name, its didn't work), and I've referenced it because I have some
froms that I inherited from project A..
:
Code:
Function GetFormByName(ByVal stFileName As String) As Form
Dim tFormType As Type = Type.GetType(stFileName, False)
If tFormType Is Nothing Then
Dim Fullname As String = Application.ProductName & "." &
stFileName
tFormType = Type.GetType(Fullname, False, True)
If tFormType Is Nothing Then
Throw New Exception(stFileName + " could not be found")
End If
End If
Return CType(Activator.CreateInstance(tFormType), Form)
End Function

Thanks


Jun 27 '08 #5
Ohad,

Then you have simple first to splits that "other" project.

Cor

"Ohad weiss" <oh***@netvision.net.ilschreef in bericht
news:eg**************@TK2MSFTNGP03.phx.gbl...
Because its another exe project.
I'll try to explain:
I have a project that its results is dll. It contains that main app
form(mdi paren), login form, and general form. This project result a dll
file.
In the same solution I have another 2 projects that their result is exe
file (each on of them). tese two projects has classes that inherit from
the general form in the project that created the dll.
In one of my classes in the exe projects, I need to scan a class in the
second exe project and retrieve the controls on it. This is why I cant use
it as a dll.

Is there any way to set reference to an exe project?

If I change the second param in the function tFormType =
Type.GetType(Fullname, False, True) to true, I get an exception about the
assembly:
Could not load type X from assembly Y, version=1.0...., culture=neutral,
publickeytoken=null.
X- the path and the fulename I'm trying to retrive (which is in project X)
Y - the name of project Y from which I'm trying to call the form in the
second project
Is there any way to set reference to an exe project? Or maybe you can
explain me how to set another assembly to the project

I can send the code if needed.

Thanks Ohad

"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:19**********************************@microsof t.com...
>Ohad

Then why not simple make a DLL from it?

Cor

"Ohad weiss" <oh***@netvision.net.ilschreef in bericht
news:eY**************@TK2MSFTNGP03.phx.gbl...
>>Thanks for the reply Cor,
But the project I'm trying to find its class (Project A) is of type Exe
and not Dll.
Therefore, I can't add a reference to it.

Ohad

"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:4B**********************************@micros oft.com...
Ohad

Simple use one the reference box which you can find in the Solution
explorer at top of a project of in the Project menu.

You can directly point to the other project in your solution, or to the
DLL that it has created.
Be aware that you have to in the Build options which projects and in
what other they have to be build.

As well, don't forget to set the Import directive to your namespace.
Otherwise you have to set that everytime in your code.

Cor

"Ohad weiss" <oh***@netvision.net.ilschreef in bericht
news:eu**************@TK2MSFTNGP03.phx.gbl...
Hi all,
>
I have a class in project A.
At the same solution, I have another project - named project B.
>
I want to write a piece of code in that class from project B that
finds the class in project A. How can I do that?
>
I have a code to do that, if the class is in the same project (by
using Application.ProductName, but even if I chaned it to the second
project name, its didn't work), and I've referenced it because I have
some froms that I inherited from project A..
:
>
>
Code:
Function GetFormByName(ByVal stFileName As String) As Form
Dim tFormType As Type = Type.GetType(stFileName, False)
If tFormType Is Nothing Then
Dim Fullname As String = Application.ProductName & "." &
stFileName
tFormType = Type.GetType(Fullname, False, True)
If tFormType Is Nothing Then
Throw New Exception(stFileName + " could not be found")
End If
End If
Return CType(Activator.CreateInstance(tFormType), Form)
End Function
>
Thanks
>
>

Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chi Tang | last post by:
Hi, I have 2 questions: How to call a class member function from another class and these 2 classes are in the same namespace? Also, how to use another project's dialog box and this 2...
2
by: Brian Reed | last post by:
I have three projects in the same solution that are all class library projects. The projects are COM interop objects that will be used within my COM framework. It is important to me to have all...
3
by: Brett P | last post by:
Hello, I am a C# developer working for a state agency. We are currently trying to come up with a standard approach for using Visual Source Safe (VSS). I have read the team development articles...
4
by: Robert W. | last post by:
I'm building a simple application that consists of two projects: - Desktop - DataObjects 'Desktop' consists of the forms for the app whereas 'DataObjects' consists of utility classes that will...
5
by: z. f. | last post by:
Hi, I'm working on a web project and i create classes to do business logic and connect to DB. i also need a windows application to do the same functionality as defined in classes inside the...
4
by: Brian Shannon | last post by:
I am playing around with class libraries trying to understand how they work. I created a class library, library.vb. I placed the library.dll into the bin directory and set my reference. If I...
3
by: koffieautomaat | last post by:
I've made one solution containing two projects. The first projects contains a control libary (dll) with a reusable class. The other projects contains a from which i wanna talk to the dll made by...
2
by: semedao | last post by:
Hi All, I developed Outlook add-in with VS 2005 , everything work fine , until the machine reboot unnormally , when I opened the solution again many projects was not there ! (I have more then...
8
by: shapper | last post by:
Hello, I am working with VS 2008 and created a Web Application Project. I added a class but whatever I do the class is not visible to my aspx pages or anywhere else. I then changed the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.