How to write DependentUpon sentences for C # files in subdirectories?

We are trying to get our C # application to compile and run using

  • Visual Studio 10 (with Microsoft compiler) on Windows and
  • MonoDevelop with gmcs, on Linux

However, sections like this in .csproj files (for Visual Studio):

 <Compile Include="Foo\Bar.cs" /> <EmbeddedResource Include="Foo\Bar.resx"> <DependentUpon>Bar.cs</DependentUpon> </EmbeddedResource> 

must be changed as follows before they work with MonoDevelop / gmcs (if not, MissingManifestResourceException will be thrown at the time resources.GetObject () is executed ):

 <Compile Include="Foo\Bar.cs" /> <EmbeddedResource Include="Foo\Bar.resx"> <DependentUpon>Foo\Bar.cs</DependentUpon> </EmbeddedResource> 

How to rewrite this in a form that they both will take? (Of course, the DependentUpon is not removed.)

+7
visual-studio monodevelop csproj
source share
1 answer

Meanwhile, I explored a couple of ways to handle the situation.

For example, it may be possible to add Condition attributes with the value $(VisualStudioVersion) != '' To make them conditional: Used by Visual Studio.

However, on a whim (after reading this answer ) I tried something completely different: I replaced my nested namespaces

 namespace Baz { namespace Bar { [...] } } 

with the designation of spatial names:

 namespace Baz.Bar { [...] } 

and voilà, MissingManifestResourceException no longer exists, even with the original DependentUpon clause.

The problem is resolved, but I do not know why.

+3
source share

All Articles