I have a project written in vb.net and I am trying to convert it to c#.
I have managed to convert it except from one file.
Here is the old code of the file : MyWebExtension.vb

#If _MyType <> "Empty" Then

Namespace My
    ''' <summary>
    ''' Module used to define the properties that are available in the My Namespace for Web projects.
    ''' </summary>
    ''' <remarks></remarks>
    <Global.Microsoft.VisualBasic.HideModuleName()> _
    Module MyWebExtension
        Private s_Computer As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Devices.ServerComputer)
        Private s_User As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.ApplicationServices.WebUser)
        Private s_Log As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Logging.AspLog)
        ''' <summary>
        ''' Returns information about the host computer.
        ''' </summary>
        <Global.System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")> _
        Friend ReadOnly Property Computer() As Global.Microsoft.VisualBasic.Devices.ServerComputer
            Get
                Return s_Computer.GetInstance()
            End Get
        End Property
        ''' <summary>
        ''' Returns information for the current Web user.
        ''' </summary>
        <Global.System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")> _
        Friend ReadOnly Property User() As Global.Microsoft.VisualBasic.ApplicationServices.WebUser
            Get
                Return s_User.GetInstance()
            End Get
        End Property
        ''' <summary>
        ''' Returns Request object.
        ''' </summary>
        <Global.System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")> _
        <Global.System.ComponentModel.Design.HelpKeyword("My.Request")> _
        Friend ReadOnly Property Request() As Global.System.Web.HttpRequest
            <Global.System.Diagnostics.DebuggerHidden()> _
            Get
                Dim CurrentContext As Global.System.Web.HttpContext = Global.System.Web.HttpContext.Current
                If CurrentContext IsNot Nothing Then
                    Return CurrentContext.Request
                End If
                Return Nothing
            End Get
        End Property
        ''' <summary>
        ''' Returns Response object.
        ''' </summary>
        <Global.System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")> _
         <Global.System.ComponentModel.Design.HelpKeyword("My.Response")> _
         Friend ReadOnly Property Response() As Global.System.Web.HttpResponse
            <Global.System.Diagnostics.DebuggerHidden()> _
            Get
                Dim CurrentContext As Global.System.Web.HttpContext = Global.System.Web.HttpContext.Current
                If CurrentContext IsNot Nothing Then
                    Return CurrentContext.Response
                End If
                Return Nothing
            End Get
        End Property
        ''' <summary>
        ''' Returns the Asp log object.
        ''' </summary>
        <Global.System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")> _
        Friend ReadOnly Property Log() As Global.Microsoft.VisualBasic.Logging.AspLog
            Get
                Return s_Log.GetInstance()
            End Get
        End Property
     End Module
End Namespace

#End If

And here is the code that a utility tried with no success :

//INSTANT C# TODO TASK: C# compiler constants cannot be set to explicit values:
//INSTANT C# NOTE: Formerly VB project-level imports:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Xml.Linq;
using System.Diagnostics;
using System.Collections.Specialized;
using System.Configuration;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Caching;
using System.Web.SessionState;
using System.Web.Security;
using System.Web.Profile;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace UWESA.Web
{
#if _MyType != "Empty"

	namespace My
	{
		/// <summary>
		/// Module used to define the properties that are available in the My Namespace for Web projects.
		/// </summary>
		/// <remarks></remarks>
		
		internal static class MyWebExtension
		{
			private static ThreadSafeObjectProvider<Microsoft.VisualBasic.Devices.ServerComputer> s_Computer = new ThreadSafeObjectProvider<Microsoft.VisualBasic.Devices.ServerComputer>();
			private static ThreadSafeObjectProvider<Microsoft.VisualBasic.ApplicationServices.WebUser> s_User = new ThreadSafeObjectProvider<Microsoft.VisualBasic.ApplicationServices.WebUser>();
			private static ThreadSafeObjectProvider<Microsoft.VisualBasic.Logging.AspLog> s_Log = new ThreadSafeObjectProvider<Microsoft.VisualBasic.Logging.AspLog>();
			/// <summary>
			/// Returns information about the host computer.
			/// </summary>
			[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
			internal static Microsoft.VisualBasic.Devices.ServerComputer Computer
			{
				get
				{
					return s_Computer.GetInstance();
				}
			}
			/// <summary>
			/// Returns information for the current Web user.
			/// </summary>
			[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
			internal static Microsoft.VisualBasic.ApplicationServices.WebUser User
			{
				get
				{
					return s_User.GetInstance();
				}
			}
			/// <summary>
			/// Returns Request object.
			/// </summary>
			[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode"), global::System.ComponentModel.Design.HelpKeyword("My.Request")]
			internal static global::System.Web.HttpRequest Request
			{
				[global::System.Diagnostics.DebuggerHidden()]
				get
				{
					global::System.Web.HttpContext CurrentContext = global::System.Web.HttpContext.Current;
					if (CurrentContext != null)
					{
						return CurrentContext.Request;
					}
					return null;
				}
			}
			/// <summary>
			/// Returns Response object.
			/// </summary>
			[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode"), global::System.ComponentModel.Design.HelpKeyword("My.Response")]
			internal static global::System.Web.HttpResponse Response
			{
				[global::System.Diagnostics.DebuggerHidden()]
				get
				{
					global::System.Web.HttpContext CurrentContext = global::System.Web.HttpContext.Current;
					if (CurrentContext != null)
					{
						return CurrentContext.Response;
					}
					return null;
				}
			}
			/// <summary>
			/// Returns the Asp log object.
			/// </summary>
			[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
			internal static Microsoft.VisualBasic.Logging.AspLog Log
			{
				get
				{
					return s_Log.GetInstance();
				}
			}
		 }
	}

	#endif
} //end of root namespace

Here's the errors I get :
Error 1 Invalid preprocessor expression D:\UWESA\trunk\source\uwesa_web_CS\Properties\MyExtensions\MyWebExtension.cs 26 16 uwesa_web
Error 2 The type or namespace name 'ThreadSafeObjectProvider' could not be found (are you missing a using directive or an assembly reference?) D:\UWESA\trunk\source\uwesa_web_CS\Properties\MyExtensions\MyWebExtension.cs 37 107 uwesa_web
Error 3 The type or namespace name 'ThreadSafeObjectProvider' could not be found (are you missing a using directive or an assembly reference?) D:\UWESA\trunk\source\uwesa_web_CS\Properties\MyExtensions\MyWebExtension.cs 38 108 uwesa_web
Error 4 The type or namespace name 'ThreadSafeObjectProvider' could not be found (are you missing a using directive or an assembly reference?) D:\UWESA\trunk\source\uwesa_web_CS\Properties\MyExtensions\MyWebExtension.cs 39 94 uwesa_web

I don't know if it is relevant but the vb.net coder has used ajax toolkit.
How can I properly convert this file?
Thank you!

First things first is _MyType a string? because you are comparing it to a string. And second is ThreadSafeObjectProvider a public class, if so did you declare all the references you need? Thats about all I can do with what you gave me. I have never converted a source file into another language though so I can't give you no help there.

Edited 6 Years Ago by noey699: bad typo

This article has been dead for over six months. Start a new discussion instead.