EugeneTrukhin
asked on
Converting one line from c# to vb.net
Hello,
I want to convert one simple c# line into vb.net and i can't do it. I don't know vb.net that much, and I spend some time searching on MSDN and I didnt find any samples.
protected ResourceManager LocRM;
LocRM= new ResourceManager("MyProject .Resources .ProjectCo ntrol", typeof(ProjectControl).Ass embly);
And the purpose of this is to read data from my resource file which i have in /MyProject/Resources and which is called ProjectControl.resx
i did this:
Protected LocRM As ResourceManager
and then the next line i cant convert...anyone can help?
I want to convert one simple c# line into vb.net and i can't do it. I don't know vb.net that much, and I spend some time searching on MSDN and I didnt find any samples.
protected ResourceManager LocRM;
LocRM= new ResourceManager("MyProject
And the purpose of this is to read data from my resource file which i have in /MyProject/Resources and which is called ProjectControl.resx
i did this:
Protected LocRM As ResourceManager
and then the next line i cant convert...anyone can help?
ASKER
Me.GetType.Assembly doesnt work because i want to read not from the resource file associated with that particular page but from another resource file which is stored in another directory. Me.GetType.Assembly --> Im getting an assembly associated with that particular page but I wanna read another assembly...
In c# it works LocRM= new ResourceManager("MyProject .Resources .ProjectCo ntrol", typeof(ProjectControl).Ass embly); but this "typeof(ProjectControl).As sembly" part I dont know how to represent in vb.net
In c# it works LocRM= new ResourceManager("MyProject
try CType(ProjectControl).Asse mbly
ASKER
no it doesnt work because Ctype expects an expression and the type.
I think
Type.GetType("ProjectContr ol").Assem bly
should get you the Assembly associated with "ProjectControl", making the whole line:
Dim LocRM As ResourceManager = New ResourceManager("MyProject .Resources .ProjectCo ntrol", Type.GetType("ProjectContr ol").Assem bly)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtypeclassgettypetopic.asp
Type.GetType("ProjectContr
should get you the Assembly associated with "ProjectControl", making the whole line:
Dim LocRM As ResourceManager = New ResourceManager("MyProject
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtypeclassgettypetopic.asp
ASKER
I tried what you say but i get "Object reference not set to an instance of an object."....Hm, I wonder why it is so easy to do in c#, and i have so many problems with vb.net.
Does anyone have an experience reading stuff from the resource file based on the culture in vb.net?
Does anyone have an experience reading stuff from the resource file based on the culture in vb.net?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This worked:
LocRM = New ResourceManager("MyProject .ProjectCo ntrol", Type.GetType("MyProject.Pr ojectContr ol.__Proje ctControl" ).Assembly )
I guess i had a problem because in vb.net the namespaces are handled differently than in c#. I tried to define the path to the resource file using c# mentality. In vb.net it's done differently.
Thank you solublefish.
LocRM = New ResourceManager("MyProject
I guess i had a problem because in vb.net the namespaces are handled differently than in c#. I tried to define the path to the resource file using c# mentality. In vb.net it's done differently.
Thank you solublefish.
LocRM=New ResourceManager("MyProject
or
Dim LocRM As ResourceManager = New ResourceManager("MyProject