473,549 Members | 2,627 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

type cannot be used as an expression

Hi

I tried to convert the following C# code to vb.net.

code in C#
_______________ _______________ _______________ _______________ ____
using System;
using System.Reflecti on;
using System.Resource s;

namespace LivingObjects.R esources
{
/// <summary>
/// This Class is used to create the ResourceManager for the site.
/// It manages a single instance of this object.
/// </summary>
internal class ResourceFactory
{
/// <summary>
/// Private Contructor. This factory is a static implementation.
/// It cannot be instanciated.
/// </summary>
private ResourceFactory ()
{
}

private static ResourceManager _rm;

public static ResourceManager ResourceManager
{
get
{
if(_rm == null)
{
lock(typeof(Liv ingObjects.Reso urces.ResourceF actory))
{
if(_rm == null)
{
string resxNamespace =
typeof(LivingOb jects.Resources .ResourceFactor y).Namespace;
_rm = new ResourceManager (resxNamespace + ".Labels",
System.Reflecti on.Assembly.Get ExecutingAssemb ly());
}
}
}
return _rm;
}
}

public static string GetLabel(string resourceID)
{
return ResourceManager .GetString(reso urceID);
}
}
}
_______________ _______________ _______________ _______________ _____________

code in VB.Net
_______________ _______________ _______________ _______________ _____________
Imports System
Imports System.Reflecti on
Imports System.Resource s

Namespace LivingObjects.R esources

' This Class is used to create the ResourceManager for the site.
' It manages a single instance of this object.

Friend Class ResourceFactory

' Private Contructor. This factory is a static implementation.
' It cannot be instanciated.
Private Sub New()
End Sub

Private Shared _rm As ResourceManager

Public Shared ReadOnly Property ResourceManager () As
ResourceManager
Get
If _rm Is Nothing Then
Lock(Type.GetTy pe(LivingObject s.Resources.Res ourceFactory))
If _rm Is Nothing Then
Dim resxNamespace As String =
Type.GetType(Li vingObjects.Res ources.Resource Factory).Namesp ace
_rm = New ResourceManager (resxNamespace +
".Labels", System.Reflecti on.Assembly.Get ExecutingAssemb ly())
End If
Unlock(Type.Get Type(LivingObje cts.Resources.R esourceFactory) )
End If
Return _rm
End Get
End Property

Public Shared Function GetLabel(ByVal resourceID As String) As
String
Return ResourceManager .GetString(reso urceID)
End Function

End Class

End Namespace
_______________ _______________ _______________ _______________ ______________

The error comes in vb.net whenever I use
'LivingObjects. Resources.Resou rceFactory'.
The build error says: "'ResourceFacto ry' is a type in 'Resources' and
cannot be used as an expression."

How can it be implemented then in vb.net? any ideas?

Thanks,

Eelis

p.s. The C# code was created by Jonathan
Gauthier.(http://www.codetools.com/cs/miscctrl...emListView.asp)
Nov 21 '05 #1
4 34735
Try replacing Type.GetType with the GetType function:

GetType(LivingO bjects.Resource s.ResourceFacto ry)
instead of:
Type.GetType(Li vingObjects.Res ources.Resource Factory)
Imran.

"eelis.net" <ee*****@yahoo. com> wrote in message
news:32******** *************** ***@posting.goo gle.com...
Hi

I tried to convert the following C# code to vb.net.

code in C#
_______________ _______________ _______________ _______________ ____
using System;
using System.Reflecti on;
using System.Resource s;

namespace LivingObjects.R esources
{
/// <summary>
/// This Class is used to create the ResourceManager for the site.
/// It manages a single instance of this object.
/// </summary>
internal class ResourceFactory
{
/// <summary>
/// Private Contructor. This factory is a static implementation.
/// It cannot be instanciated.
/// </summary>
private ResourceFactory ()
{
}

private static ResourceManager _rm;

public static ResourceManager ResourceManager
{
get
{
if(_rm == null)
{
lock(typeof(Liv ingObjects.Reso urces.ResourceF actory))
{
if(_rm == null)
{
string resxNamespace =
typeof(LivingOb jects.Resources .ResourceFactor y).Namespace;
_rm = new ResourceManager (resxNamespace + ".Labels",
System.Reflecti on.Assembly.Get ExecutingAssemb ly());
}
}
}
return _rm;
}
}

public static string GetLabel(string resourceID)
{
return ResourceManager .GetString(reso urceID);
}
}
}
_______________ _______________ _______________ _______________ _____________

code in VB.Net
_______________ _______________ _______________ _______________ _____________
Imports System
Imports System.Reflecti on
Imports System.Resource s

Namespace LivingObjects.R esources

' This Class is used to create the ResourceManager for the site.
' It manages a single instance of this object.

Friend Class ResourceFactory

' Private Contructor. This factory is a static implementation.
' It cannot be instanciated.
Private Sub New()
End Sub

Private Shared _rm As ResourceManager

Public Shared ReadOnly Property ResourceManager () As
ResourceManager
Get
If _rm Is Nothing Then
Lock(Type.GetTy pe(LivingObject s.Resources.Res ourceFactory)) If _rm Is Nothing Then
Dim resxNamespace As String =
Type.GetType(Li vingObjects.Res ources.Resource Factory).Namesp ace
_rm = New ResourceManager (resxNamespace +
".Labels", System.Reflecti on.Assembly.Get ExecutingAssemb ly())
End If
Unlock(Type.Get Type(LivingObje cts.Resources.R esourceFactory) ) End If
Return _rm
End Get
End Property

Public Shared Function GetLabel(ByVal resourceID As String) As
String
Return ResourceManager .GetString(reso urceID)
End Function

End Class

End Namespace
_______________ _______________ _______________ _______________ ______________

The error comes in vb.net whenever I use
'LivingObjects. Resources.Resou rceFactory'.
The build error says: "'ResourceFacto ry' is a type in 'Resources' and
cannot be used as an expression."

How can it be implemented then in vb.net? any ideas?

Thanks,

Eelis

p.s. The C# code was created by Jonathan
Gauthier.(http://www.codetools.com/cs/miscctrl...emListView.asp)

Nov 21 '05 #2
Hi again

That didn't work either. It makes a build error described as:
"value of type 'System.Type' cannot be converted to 'Integer'" for the
whole expression (GetType(Living Objects.Resourc es.ResourceFact ory)).

Any other ideas...

Thanks a lot!

eelis

"Imran Koradia" <no****@microso ft.com> wrote in message news:<OG******* *******@TK2MSFT NGP11.phx.gbl>. ..
Try replacing Type.GetType with the GetType function:

GetType(LivingO bjects.Resource s.ResourceFacto ry)
instead of:
Type.GetType(Li vingObjects.Res ources.Resource Factory)
Imran.

Nov 21 '05 #3

"eelis.net" <ee*****@yahoo. com> wrote
That didn't work either. It makes a build error described as:
"value of type 'System.Type' cannot be converted to 'Integer'" for the
whole expression (GetType(Living Objects.Resourc es.ResourceFact ory)).

Any other ideas...

How about

LivingObjects.R esources.Resour ceFactory.GetTy pe.Namespace
The docs say GetType expects a string, at best you're giving it
an object. If the above doesn't work, try passing it a string with
that full name in it.

HTH
LFS

Nov 21 '05 #4
Sorry for the late reply - my outlook express is way out of whack with
message threads.

Anyway, the 'lock' in C# and VB.NET mean different things. Here's how your
VB.NET code should look like:

Imports System
Imports System.Reflecti on
Imports System.Resource s

Namespace LivingObjects.R esources

' This Class is used to create the ResourceManager for the site.
' It manages a single instance of this object.

Friend Class ResourceFactory

' Private Contructor. This factory is a static implementation.
' It cannot be instanciated.
Private Sub New()
End Sub

Private Shared _rm As ResourceManager

Public Shared ReadOnly Property _
ResourceManager () As ResourceManager
Get
If _rm Is Nothing Then
SyncLock GetType( _
LivingObjects.R esources.Resour ceFactory)
If _rm Is Nothing Then
Dim resxNamespace As String = _
GetType( _

LivingObjects.R esources.Resour ceFactory).Name space
_rm = New ResourceManager (resxNamespace + ".Labels",
_

System.Reflecti on.Assembly.Get ExecutingAssemb ly())
End If
End SyncLock
End If
Return _rm
End Get
End Property

Public Shared Function GetLabel( _
ByVal resourceID As String) As String
Return ResourceManager .GetString(reso urceID)
End Function

End Class

End Namespace
hope that helps..
Imran.

"eelis.net" <ee*****@yahoo. com> wrote in message
news:32******** *************** ***@posting.goo gle.com...
Hi again

That didn't work either. It makes a build error described as:
"value of type 'System.Type' cannot be converted to 'Integer'" for the
whole expression (GetType(Living Objects.Resourc es.ResourceFact ory)).

Any other ideas...

Thanks a lot!

eelis

"Imran Koradia" <no****@microso ft.com> wrote in message

news:<OG******* *******@TK2MSFT NGP11.phx.gbl>. ..
Try replacing Type.GetType with the GetType function:

GetType(LivingO bjects.Resource s.ResourceFacto ry)
instead of:
Type.GetType(Li vingObjects.Res ources.Resource Factory)
Imran.

Nov 21 '05 #5

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

Similar topics

21
4498
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
51
4472
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is there something wrong in there? -------------------------------------------------------------------- Types A type is a definition for a sequence of...
59
3414
by: Michael C | last post by:
eg void DoIt() { int i = FromString("1"); double d = FromString("1.1"); } int FromString(string SomeValue) {
0
547
by: eelis.net | last post by:
Hi I tried to convert the following C# code to vb.net. code in C# ________________________________________________________________ using System; using System.Reflection; using System.Resources;
1
1583
by: Angel Tsankov | last post by:
Does the C++ standard define what should happen if the size of int in the following code cannot accommodate the bit field? struct bit_fields { unsigned int digit:17; // int is 16 bits };
669
25607
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990....
4
2094
by: zaeminkr | last post by:
I got a good answer here I have still confusing part. I have two very simple classes class DRect { private : double x0, y0, x1, y1; public : DRect(double a, double b, double c, double d) : x0(a), y0(b),
8
4567
by: minseokoh | last post by:
Hi, Could someone explain why "const" is located after the function name and what it means? inline unsigned char *access(int off) const { if (off < 0) abort(); return (&bits_); }
0
1347
by: Anonymous | last post by:
Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <wfednQ6STZz2Z6faRVnytAA@bt.com> Lines: 15 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 86.160.229.79 X-AuthenticatedUsername: NoAuthUser X-Trace:...
0
7521
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
0
7451
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7720
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7959
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7473
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6044
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3483
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1061
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
764
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.