I'm working on a web site project on vb.net - asp.net 4 - visual studio 2010.
I need to implement a part of code that is used only when debug compilation is chosen within visual studio, e.g.:
' do something
#if DEBUGCONST
' debug mode! do something else
#end if
' proceed as usual..
Unfortunately this is not a web application project, therefore it doesn't come with a complete "property page" (where you can change compilers constant easily).
Googling for an answer, I found:
http://msdn.microsoft.com/en-us/library/a15ebt6c%28v=vs.100%29.aspx
..and I changed my web.config in this way:
<system.codedom>
<compilers>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" compilerOptions="/define:DEBUGCONST"></compiler>
</compilers>
</system.codedom>
Unfortunately, even if it compiles fine, the DEBUGCONST is never defined and the "debug code" is never executed.
Is there something I'm missing?
Thank you in advance for any help!
Related
For the last 5-6 months I have been fighting a battle with VB code calling a c++ DLL. I have asked numerous questions on StackOverflow only to have all of them voted out of existence.
I have finally found a way of compiling my code (no help from Stackoverflow) that will work well with the C++ DLL. It appears that when I compile my VB.NET module and I use a 4.0 framework it works perfectly, no more memory issues with calling c++. Frameworks > 4.0 cause the protected memory errors.
My VB.NET code is itself a DLL and I call it from both compiled .EXE programs as well as uncompiled vb.net code from ASP.NET. When I compile it into other VB.NET programs everything works well. When I run it from ASP.NET I get;
Attempted to read or write protected memory.
This is the same error I would get when I previously compiled with a Framework > v4.0. I have modified my web.config file adding;
<compilation debug="false" targetFramework="4.0"/>
and
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v4.0" />
<providerOption name="OptionInfer" value="true" />
<providerOption name="WarnAsError" value="false" />
</compiler>
With no change in behavior. Since the memory error is similar to what I get when I execute this same code compiled with a framework > 4.0 my assumption is IIS is executing the code with a framework > 4.0.
The questions as best I can formulate them are;
How can I verify what framework the DLL is executing in?
How can I control that framework?
Hopefully this question lasts long enough to get an answer, rather than voted down the tubes.
I am trying to host my application in Azure but getting below error:
Compiler Error Message: CS1056: Unexpected character '$'
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2623.0
I have used string concatenation using '$' sign.
This works fine in my local machine, but throws the compilation error.
How to set the right framework version in Azure and avoid the above exception.
Thanks,
Sharath
Lex should get credit for sending this in the correct direction. I want to confirm that this is the correct path and fixes the issue and give a little more detail. I was having the same issue and error message "Compiler Error Message: CS1056: Unexpected character '$'" when trying to deploy a ASP.NET app to Microsoft Azure App Service and indeed the solution was to add the Roslyn compiler to the project. It appears by default the built in compiler used on Microsoft Azure App Service only supports up to C# 5 language features and Roslyn is needed to compile and use the C# 6 features. Note I am deploying CS files for my project and not compiled DLL files.
Install Roslyn In Project
In Visual Studio 2017 Select "Tools" -> "NuGet Package Manager" -> "Manage NuGet Packages for Solution..."
From the tabs select "Browse" and then search for "Microsoft.CodeDom.Providers.DotNetCompilerPlatform"
Select "Microsoft.CodeDom.Providers.DotNetCompilerPlatform" from the search results then over on the right check the project name you want to add it to and then click the "Install" button.
Rebuild your Solution and make sure it still builds.
Deploy with Roslyn
You will notice installing the DotNetCompilerPlatform package added a section to your Web.config file that looks something like this, make sure this section gets added to your deployed Web.config:
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
</compilers></system.codedom>
You will also notice installing the DotNetCompilerPlatform package and building your solution added some files to your Bin folder, make sure these files (including the whole "roslyn" folder and all the files in it) get put in the Bin folder of your deploy: Bin folder files to deploy
That was all it took to get my website back up and running with C# 6 language features, hope it helps.
You can install Microsoft.Dotnet.Compilers package and then compile your site again.
Refer this page - Project builds fine with Visual Studio but fails from the command line
I am deploying an ASP.NET MVC 4 application on IIS 7.5 on a Windows 2008 R2 machine.
The app works alright locally in the Visual Studio Web development server.
But when deployed, I get a 504 http status code.
The app runs in a custom application pool under the ApplicationPoolIdentity identity and in Integrated mode. The app pool is enabled to run both 32-bit and 64-bit applications and targets v4 of the .NET framework.
The app assemblies were build targeting "Any CPU".
When I deploy the application and attempt to access it, in addition to receiving the 504 Http status code, I also see this in the event viewer.
Event Data
HRESULT 0x8007000d
PhysicalPath \\?\C:\Windows\Microsoft.NET\Framework\v4.0.30319\CONFIG\web.config
Type 3
Message Unrecognized element 'providerOption'
LineNumber 53
PreviousLine <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
ErrorLine <providerOption name="CompilerVersion" value="v4.0"/>
NextLine <providerOption name="WarnAsError" value="false"/>
The above configuration pertains to CodeDOM, a set of classes in the System.CodeDom namespace in the System.dll assembly that ASP.NET uses to generate our "code behind" classes.
The CodeDOM configuration has changed from v2 of the .NET framework to v3.5.
I missed the part where the above error gives me the path of the web.config it is complaining about. The path is C:\Windows\Microsoft.NET\Framework\v4.0.30319\CONFIG\web.config and that file did have this <providerOption> element.
I commented that out. This error is now gone.
However, I still have other issues to deal with but this one goes away. So, anyone else in the future who faces this error might use this answer as help.
I have seen the posts on this site about the following error:
The breakpoint will not currently be hit. No symbols have been loaded for this document.
But, the problem descriptions and solutions haven't addressed the situation I am experiencing so, I hope to get some clarification.
I am using Visual Studio 2010, and working on a very large, somewhat old ASP.NET web application that targets .NET v2. The first page of the application is Login.aspx. If I put a break point on the first line of code within the Page_Load event of the Login.aspx page. I get the yellowed-out warning icon on the break point, with the message above. If, while in debug mode, I go to Debug >> Windows >> Modules, I see that App_Web_login.aspx.cdcab7d2.DLL has a Symbol Status that reads "No symbols loaded". The Path for the symbols is like this:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files...\App_Web_login.aspx.cdcab7d2.DLL. I have checked that path, and a DLL file does exist there. So, if I right-click on this listing in the Modules page, and select "Load symbols from " and "Symbols Path", I get a dialog box, pointing to the path I just listed but, it is asking for a .pdb file! There is no .pdb file in that directory. Actually there is no App_Web_login.aspx.cdcab7d2.pdb file anywhere on my machine.
Also, there is an App_Web_login.aspx.cdcab7d2.DLL file located in the bin folder of my project. I was hoping that Visual Studio would generate a new .dll file there if I rebuilt the project. But, if I remove that .dll file, the project won't build.
Very confusing.
How can I get the symbols file situation straightened out?
Thanks, in advance, for any help you can provide.
Special Note: Here is what is listed in the element of the web.config file:
<compilation defaultLanguage="vb" debug="true">
<compilers>
<compiler language="vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" extension=".VB" compilerOptions="/define:Debug=True /define:Trace=True /imports:Microsoft.VisualBasic,System,System.Collections,System.Configuration,System.Data,System.Drawing,System.Web,System.Web.UI,System.Web.UI.HtmlControls,System.Web.UI.WebControls"/>
</compilers>
<assemblies>...
Thanks again for any help...
I have the following nant task:
<!--Compiles the possible release candidate to be used for further testing and possible release -->
<target name="createReleaseCandidateJob">
<xmlpoke file="${nant.project.basedir}/${webApplicationProjectName}/Web.config"
xpath="/configuration/system.web/compilation/#debug"
value="false" />
<exec basedir="." program="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe"
commandline="-p ${webApplicationProjectName} -v / ${releaseCandidateOutputDir}"
workingdir="."
failonerror="true"
/>
<echo>Completed Compile RC Job</echo>
</target>
I also have the following line of code included in my project:
myVersion = "2.0b";
#if DEBUG
myVersion = Guid.NewId().ToString();
#endif
this is used when loading certain assets (swf files) by being appended as a querystring parameter and ensures that when debugging a cached version isn't received but is manageable once released.
However, after what I believed should be compiling a relase build, the version is still being set as a Guid indicating I'm not achieving a release build yet. I've checked the web.config and the value of debug is changed to false so I'm assuming I'm missing some setting in the aspnet_compiler.exe arguments, but I cant find anything which indicates such in the documentation.
The aspnet_compiler can tell the difference between a debug and 'retail' compile using the web.config value, but the conditionals are usually passed as an argument to the compiler (see this) by whatever is driving the build (e.g. Visual Studio, NAnt or whatever). The ASP compiler doesn't have that, so you need to include them in the codedom section of the web.config file:
<system.codedom>
<compilers>
<compiler
language="c#;cs;csharp"
extension=".cs"
warningLevel="4"
compilerOptions="/d:DEBUG"
type="Microsoft.CSharp.CSharpCodeProvider,
System, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
</compilers>
</system.codedom>
Here, compilerOptions provides the #DEBUG definition you need. That will be picked up by the compiler itself when invoked by aspnet_compiler and should be reflected in the #conditional blocks in your code. So remember to change that as well when you switch the other debug flag in your web.config.