assembly always gets built optimized

B

bonk

I have a c# project as part of a larger VS 2005 solution that always
gets build optimized and I therefore can not evaluate any values while
debugging through the code ("Cannot evaluate expression because the
code of the current method is optimized."). This happens alltough the
checkbock "optimize code" in the project settings is switched off. My
question here is what are possible conditions that would make an
assembly be build as optimized even if the project settings state
otherwise. Do the referenced assemblies play a role here? This is a
Winforms WPF interop assembly that references wpf and windows forms.
The hole WPF UI is build using my own c# code so no wpf msbuild tasks
are needed. I attached the project file. Maybe you see something that
I miss.


<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/
developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition="'$(Configuration)'==''">Debug</
Configuration>
<DefaultClrNameSpace>OperationCanvasTest</DefaultClrNameSpace>
<AssemblyName>AIS.VCTC3.OperationEditor</AssemblyName>
<OutputPath>bin\$(Configuration)\</OutputPath>
<ApplicationVersion>1.0.0.*</ApplicationVersion>
<ApplicationRevision>0</ApplicationRevision>
<AlwaysCompileMarkupFilesInSeparateDomain>false</
AlwaysCompileMarkupFilesInSeparateDomain>
<OutputType>Library</OutputType>
<RootNamespace>AIS.VCTC3.OperationEditor</RootNamespace>
<ApplicationIcon>
</ApplicationIcon>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ProjectGuid>{4BDDDA83-1DD1-4C33-8DF3-32B114E046FD}</ProjectGuid>
<StartupObject>
</StartupObject>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>
</DefineConstants>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisRuleAssemblies>C:\Programme\Microsoft Visual Studio
8\Team Tools\Static Analysis Tools\FxCop\\rules</
CodeAnalysisRuleAssemblies>
<CodeAnalysisUseTypeNameInSuppression>true</
CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</
CodeAnalysisModuleSuppressionsFile>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<UseVSHostingProcess>false</UseVSHostingProcess>
<Optimize>false</Optimize>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="Process.Net, Version=0.0.0.0, Culture=neutral">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Programme\AIS\VACNT-32.42\System\Release\Process.Net.dll</
HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationProvider" />
<Reference Include="WindowsBase" />
<Reference Include="WindowsFormsIntegration" />
<Compile Include="DragDropScrollViewer.cs" />
<Compile Include="OperationCanvas.cs" />
<Compile Include="OperationEdior.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="OperationEdior.Designer.cs">
<DependentUpon>OperationEdior.cs</DependentUpon>
</Compile>
<Compile Include="OperationVisual.cs" />
<Compile Include="Timeline.cs" />
</ItemGroup>
<PropertyGroup>
<PostBuildEvent>xcopy /Y "$(TargetDir)$(TargetName).*" "$(SolutionDir)
\out\$(ConfigurationName)\"</PostBuildEvent>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\AIS.VCTC3.Core\AIS.VCTC3.Core.csproj">
<Project>{C365BE10-1043-4897-8D69-15643306EAE2}</Project>
<Name>AIS.VCTC3.Core</Name>
</ProjectReference>
<ProjectReference Include="..\AIS.VCTC3.Interface
\AIS.VCTC3.Interface.csproj">
<Project>{E5F7E025-164E-4F64-BF06-9AD00301BC1E}</Project>
<Name>AIS.VCTC3.Interface</Name>
</ProjectReference>
<ProjectReference Include="..\AIS.VCTC3.Kit\AIS.VCTC3.Kit.csproj">
<Project>{7BF1753E-853B-40C9-94F2-C943A4399980}</Project>
<Name>AIS.VCTC3.Kit</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="OperationEdior.resx">
<SubType>Designer</SubType>
<DependentUpon>OperationEdior.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
</Project>
 
N

Nicholas Paldino [.NET/C# MVP]

Bonk,

It's not the optimize flag which causes you to not be able to debug. My
guess is that you have your project configured for release, and that is why
you can't debug it.

Hope this helps.
 
R

Robert Ludig

Bonk,

It's not the optimize flag which causes you to not be able to debug. My
guess is that you have your project configured for release, and that is why
you can't debug it.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




I have a c# project as part of a larger VS 2005 solution that always
gets build optimized and I therefore can not evaluate any values while
debugging through the code ("Cannot evaluate expression because the
code of the current method is optimized."). This happens alltough the
checkbock "optimize code" in the project settings is switched off. My
question here is what are possible conditions that would make an
assembly be build as optimized even if the project settings state
otherwise. Do the referenced assemblies play a role here? This is a
Winforms WPF interop assembly that references wpf and windows forms.
The hole WPF UI is build using my own c# code so no wpf msbuild tasks
are needed. I attached the project file. Maybe you see something that
I miss.
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/
developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition="'$(Configuration)'==''">Debug</
Configuration>
<DefaultClrNameSpace>OperationCanvasTest</DefaultClrNameSpace>
<AssemblyName>AIS.VCTC3.OperationEditor</AssemblyName>
<OutputPath>bin\$(Configuration)\</OutputPath>
<ApplicationVersion>1.0.0.*</ApplicationVersion>
<ApplicationRevision>0</ApplicationRevision>
<AlwaysCompileMarkupFilesInSeparateDomain>false</
AlwaysCompileMarkupFilesInSeparateDomain>
<OutputType>Library</OutputType>
<RootNamespace>AIS.VCTC3.OperationEditor</RootNamespace>
<ApplicationIcon>
</ApplicationIcon>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ProjectGuid>{4BDDDA83-1DD1-4C33-8DF3-32B114E046FD}</ProjectGuid>
<StartupObject>
</StartupObject>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>
</DefineConstants>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisRuleAssemblies>C:\Programme\Microsoft Visual Studio
8\Team Tools\Static Analysis Tools\FxCop\\rules</
CodeAnalysisRuleAssemblies>
<CodeAnalysisUseTypeNameInSuppression>true</
CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</
CodeAnalysisModuleSuppressionsFile>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<UseVSHostingProcess>false</UseVSHostingProcess>
<Optimize>false</Optimize>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="Process.Net, Version=0.0.0.0, Culture=neutral">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Programme\AIS\VACNT-32.42\System\Release\Process.Net.dll</
HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationProvider" />
<Reference Include="WindowsBase" />
<Reference Include="WindowsFormsIntegration" />
<Compile Include="DragDropScrollViewer.cs" />
<Compile Include="OperationCanvas.cs" />
<Compile Include="OperationEdior.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="OperationEdior.Designer.cs">
<DependentUpon>OperationEdior.cs</DependentUpon>
</Compile>
<Compile Include="OperationVisual.cs" />
<Compile Include="Timeline.cs" />
</ItemGroup>
<PropertyGroup>
<PostBuildEvent>xcopy /Y "$(TargetDir)$(TargetName).*" "$(SolutionDir)
\out\$(ConfigurationName)\"</PostBuildEvent>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\AIS.VCTC3.Core\AIS.VCTC3.Core.csproj">
<Project>{C365BE10-1043-4897-8D69-15643306EAE2}</Project>
<Name>AIS.VCTC3.Core</Name>
</ProjectReference>
<ProjectReference Include="..\AIS.VCTC3.Interface
\AIS.VCTC3.Interface.csproj">
<Project>{E5F7E025-164E-4F64-BF06-9AD00301BC1E}</Project>
<Name>AIS.VCTC3.Interface</Name>
</ProjectReference>
<ProjectReference Include="..\AIS.VCTC3.Kit\AIS.VCTC3.Kit.csproj">
<Project>{7BF1753E-853B-40C9-94F2-C943A4399980}</Project>
<Name>AIS.VCTC3.Kit</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="OperationEdior.resx">
<SubType>Designer</SubType>
<DependentUpon>OperationEdior.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
</Project>- Zitierten Text ausblenden -

- Zitierten Text anzeigen -

What do you mean by "configured for release"? The active configuration
that I use when I hit F5 is Debug|AnyCPU. What settings actually make
a project configured for release ? Just DEBUG not being defined ?
That'd be strange since I can debug other projects in release mode
(without DEBUG being defined but with debug symbols loaded) just fine.
 
W

Willy Denoyette [MVP]

Robert Ludig said:
Bonk,

It's not the optimize flag which causes you to not be able to debug. My
guess is that you have your project configured for release, and that is why
you can't debug it.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




I have a c# project as part of a larger VS 2005 solution that always
gets build optimized and I therefore can not evaluate any values while
debugging through the code ("Cannot evaluate expression because the
code of the current method is optimized."). This happens alltough the
checkbock "optimize code" in the project settings is switched off. My
question here is what are possible conditions that would make an
assembly be build as optimized even if the project settings state
otherwise. Do the referenced assemblies play a role here? This is a
Winforms WPF interop assembly that references wpf and windows forms.
The hole WPF UI is build using my own c# code so no wpf msbuild tasks
are needed. I attached the project file. Maybe you see something that
I miss.
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/
developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition="'$(Configuration)'==''">Debug</
Configuration>
<DefaultClrNameSpace>OperationCanvasTest</DefaultClrNameSpace>
<AssemblyName>AIS.VCTC3.OperationEditor</AssemblyName>
<OutputPath>bin\$(Configuration)\</OutputPath>
<ApplicationVersion>1.0.0.*</ApplicationVersion>
<ApplicationRevision>0</ApplicationRevision>
<AlwaysCompileMarkupFilesInSeparateDomain>false</
AlwaysCompileMarkupFilesInSeparateDomain>
<OutputType>Library</OutputType>
<RootNamespace>AIS.VCTC3.OperationEditor</RootNamespace>
<ApplicationIcon>
</ApplicationIcon>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ProjectGuid>{4BDDDA83-1DD1-4C33-8DF3-32B114E046FD}</ProjectGuid>
<StartupObject>
</StartupObject>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>
</DefineConstants>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisRuleAssemblies>C:\Programme\Microsoft Visual Studio
8\Team Tools\Static Analysis Tools\FxCop\\rules</
CodeAnalysisRuleAssemblies>
<CodeAnalysisUseTypeNameInSuppression>true</
CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</
CodeAnalysisModuleSuppressionsFile>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<UseVSHostingProcess>false</UseVSHostingProcess>
<Optimize>false</Optimize>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="Process.Net, Version=0.0.0.0, Culture=neutral">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Programme\AIS\VACNT-32.42\System\Release\Process.Net.dll</
HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationProvider" />
<Reference Include="WindowsBase" />
<Reference Include="WindowsFormsIntegration" />
<Compile Include="DragDropScrollViewer.cs" />
<Compile Include="OperationCanvas.cs" />
<Compile Include="OperationEdior.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="OperationEdior.Designer.cs">
<DependentUpon>OperationEdior.cs</DependentUpon>
</Compile>
<Compile Include="OperationVisual.cs" />
<Compile Include="Timeline.cs" />
</ItemGroup>
<PropertyGroup>
<PostBuildEvent>xcopy /Y "$(TargetDir)$(TargetName).*" "$(SolutionDir)
\out\$(ConfigurationName)\"</PostBuildEvent>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\AIS.VCTC3.Core\AIS.VCTC3.Core.csproj">
<Project>{C365BE10-1043-4897-8D69-15643306EAE2}</Project>
<Name>AIS.VCTC3.Core</Name>
</ProjectReference>
<ProjectReference Include="..\AIS.VCTC3.Interface
\AIS.VCTC3.Interface.csproj">
<Project>{E5F7E025-164E-4F64-BF06-9AD00301BC1E}</Project>
<Name>AIS.VCTC3.Interface</Name>
</ProjectReference>
<ProjectReference Include="..\AIS.VCTC3.Kit\AIS.VCTC3.Kit.csproj">
<Project>{7BF1753E-853B-40C9-94F2-C943A4399980}</Project>
<Name>AIS.VCTC3.Kit</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="OperationEdior.resx">
<SubType>Designer</SubType>
<DependentUpon>OperationEdior.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
</Project>- Zitierten Text ausblenden -

- Zitierten Text anzeigen -

What do you mean by "configured for release"? The active configuration
that I use when I hit F5 is Debug|AnyCPU. What settings actually make
a project configured for release ? Just DEBUG not being defined ?
That'd be strange since I can debug other projects in release mode
(without DEBUG being defined but with debug symbols loaded) just fine.


What's the current method?
..... "of the current method is optimized"...
Seems like you are evaluating an expression from a method that is part of an optimized
assembly.


Willy.
 
N

Nicholas Paldino [.NET/C# MVP]

Robert,

DEBUG being defined is a by-product of the project properties. The
project, when you tell it to compile in debug mode, will define the debug
constant. When you compile in release mode, the constant will not be there.
In order to access this, you basically go to the configuration manager in
Visual Studio and set which projects are in release mode, and which are in
debug mode.

The only other thing I can guess would be the issue is that you are not
referencing the project, but rather, the compiled dll itself, which I think
would disable debugging as well.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Robert Ludig said:
Bonk,

It's not the optimize flag which causes you to not be able to debug.
My
guess is that you have your project configured for release, and that is
why
you can't debug it.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




I have a c# project as part of a larger VS 2005 solution that always
gets build optimized and I therefore can not evaluate any values while
debugging through the code ("Cannot evaluate expression because the
code of the current method is optimized."). This happens alltough the
checkbock "optimize code" in the project settings is switched off. My
question here is what are possible conditions that would make an
assembly be build as optimized even if the project settings state
otherwise. Do the referenced assemblies play a role here? This is a
Winforms WPF interop assembly that references wpf and windows forms.
The hole WPF UI is build using my own c# code so no wpf msbuild tasks
are needed. I attached the project file. Maybe you see something that
I miss.
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/
developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition="'$(Configuration)'==''">Debug</
Configuration>
<DefaultClrNameSpace>OperationCanvasTest</DefaultClrNameSpace>
<AssemblyName>AIS.VCTC3.OperationEditor</AssemblyName>
<OutputPath>bin\$(Configuration)\</OutputPath>
<ApplicationVersion>1.0.0.*</ApplicationVersion>
<ApplicationRevision>0</ApplicationRevision>
<AlwaysCompileMarkupFilesInSeparateDomain>false</
AlwaysCompileMarkupFilesInSeparateDomain>
<OutputType>Library</OutputType>
<RootNamespace>AIS.VCTC3.OperationEditor</RootNamespace>
<ApplicationIcon>
</ApplicationIcon>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ProjectGuid>{4BDDDA83-1DD1-4C33-8DF3-32B114E046FD}</ProjectGuid>
<StartupObject>
</StartupObject>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>
</DefineConstants>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisRuleAssemblies>C:\Programme\Microsoft Visual Studio
8\Team Tools\Static Analysis Tools\FxCop\\rules</
CodeAnalysisRuleAssemblies>
<CodeAnalysisUseTypeNameInSuppression>true</
CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</
CodeAnalysisModuleSuppressionsFile>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<UseVSHostingProcess>false</UseVSHostingProcess>
<Optimize>false</Optimize>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="Process.Net, Version=0.0.0.0, Culture=neutral">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Programme\AIS\VACNT-32.42\System\Release\Process.Net.dll</
HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationProvider" />
<Reference Include="WindowsBase" />
<Reference Include="WindowsFormsIntegration" />
<Compile Include="DragDropScrollViewer.cs" />
<Compile Include="OperationCanvas.cs" />
<Compile Include="OperationEdior.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="OperationEdior.Designer.cs">
<DependentUpon>OperationEdior.cs</DependentUpon>
</Compile>
<Compile Include="OperationVisual.cs" />
<Compile Include="Timeline.cs" />
</ItemGroup>
<PropertyGroup>
<PostBuildEvent>xcopy /Y "$(TargetDir)$(TargetName).*" "$(SolutionDir)
\out\$(ConfigurationName)\"</PostBuildEvent>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\AIS.VCTC3.Core\AIS.VCTC3.Core.csproj">
<Project>{C365BE10-1043-4897-8D69-15643306EAE2}</Project>
<Name>AIS.VCTC3.Core</Name>
</ProjectReference>
<ProjectReference Include="..\AIS.VCTC3.Interface
\AIS.VCTC3.Interface.csproj">
<Project>{E5F7E025-164E-4F64-BF06-9AD00301BC1E}</Project>
<Name>AIS.VCTC3.Interface</Name>
</ProjectReference>
<ProjectReference Include="..\AIS.VCTC3.Kit\AIS.VCTC3.Kit.csproj">
<Project>{7BF1753E-853B-40C9-94F2-C943A4399980}</Project>
<Name>AIS.VCTC3.Kit</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="OperationEdior.resx">
<SubType>Designer</SubType>
<DependentUpon>OperationEdior.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
</Project>- Zitierten Text ausblenden -

- Zitierten Text anzeigen -

What do you mean by "configured for release"? The active configuration
that I use when I hit F5 is Debug|AnyCPU. What settings actually make
a project configured for release ? Just DEBUG not being defined ?
That'd be strange since I can debug other projects in release mode
(without DEBUG being defined but with debug symbols loaded) just fine.
 
R

Robert Ludig

I did not mention an important detail (since I didn't think that it
matters). I attach to the process that references my assembly after
the process is started. When I do not attach visual studio to the
process but instead start the process directly from vs by hitting F5 I
infact am able to debug. Also note that the probelm with "Cannot
evaluate expression because the code of the current method is
optimized." only happens with the one project. The sourcecode of all
other projects in the same solution can be debugged just fine no
matter if I attach later or start the process with F5.
What does this hint? How could I narrow the source of this evil down?
Does it have to do something with the visual studio hosting process
(wich only is used when starting the process with F5) ? Or could it
have to do with the working folder or the loaded symbols?
 
R

Robert Ludig

Another interesting thing to note:

When I attach to the process later. The dll of the project in question
is infact optimized. That's what it says in the Modules windows
("Optimized" column says "Yes"). But when I start the process with F5
the dll of that project is not optimized ("Optimized" column says
"No"). All other projects always are not optimized. How can that
happen?
 
B

Ben Voigt

Robert Ludig said:
Another interesting thing to note:

When I attach to the process later. The dll of the project in question
is infact optimized. That's what it says in the Modules windows
("Optimized" column says "Yes"). But when I start the process with F5
the dll of that project is not optimized ("Optimized" column says
"No"). All other projects always are not optimized. How can that
happen?

The framework detects the debugger during startup, and changes a bunch of
settings. Thus to really debug production code, you have to attach and not
start in debugger.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top