C# exclude complete form / usercontrol by using compiler constants

I'd like to exclude / include a complete form in my project. But when I add the needed #if CONST and #endif the compiler complains about resources that may get wrong names.

warning MSB3042: A namespace or class definition was found within a conditional compilation directive in the file "Form1.cs". This may lead to an incorrect choice for the manifest resource name for resource "Form1.resx".

What does this mean?

And how do I fix it?

-------------Problems Reply------------

  • Explanation: A normal Form (created from a Template) consists of 2 .cs files and a .resx file. By eliminating the Form1 class you 'orphan' the resources.
  • Workarounds:

    1. Make a simpler Form without resource file.
    2. use a #else tag to create empty stubs for the Form1 class
    3. Forget about the idea and only eliminate the (few) points where the rest of the program uses the Form.

I favor 3, what benefits do you expect from removing the Form?

If you did not set images and you don't use the resx for translations (i.e. your form is not localizable) try to remove your Form1.resx.

Category:c# Views:0 Time:2009-12-17

Related post

  • project-level conditional compilation constant 2009-08-19

    I am getting a project-level conditional compilation constant error while trying to build my vb.net project. It reads: project-level conditional compilation constant 'VB_VER=9.0,TARGET="exe",CONFIG="Debug",_MyType="Console",PLATFORM="AnyCPU",DEBUG;^^

  • Bad Compile constant value 2009-10-13

    I get "Bad Compile constant value" on this statement. Regex objCheckNumber = new Regex("^(\d){4}$"); I simply want to set this up to check another string to see if the value entered is 4 digits. --------------Solutions------------- C# is trying to in

  • Using compiler constants in build events 2010-02-27

    Is there anyway to use compiler constants in Build Events in Visual Studio - VB.NET? (especially in Post-Build events) Scenario If TEST_EDITION=TRUE is defined I want to run an executable during the Post-Build event so if it's FALSE then I'll run som

  • Access Compiler Constants in code 2011-01-11

    Is it possible to use a constant defined by the compiler in code like below? #If DEALER_DEBUG = "ID12345" Then If(Dealer.ID = DEALER_DEBUG) Then 'Do something End If #End If I'm running batch processes and I'm experiencing problems with one of my cus

  • Changing EXE name based on compilation constant 2011-09-21

    I have a project in VB.NET 2010 (compiling to x86, .NET 2.0 runtime) that I want to compile into two separate EXEs - a "lite" version and a "full" version. Unfortunately I cannot make two separate projects as it uses the Adobe Reader COM control - an

  • Can SWC files be created in DEBUG and RELEASE version by using Conditional Compilation constants? 2011-11-08

    Is there a way to compile SWC files in different targets (Debug vs. Release) similarly how you can compile a SWF file with the AS3 Conditional Compiler constants? This link shows how SWF files can be compiled with predefined compiler constants: http:

  • Is there a compiler constant for Windows Runtime? 2013-05-15

    Is there a specific compiler constant for WinRT similar to the compiler constant of SILVERLIGHT and WINDOWS_PHONE? Example: #if SILVERLIGHT #if WINDOWS_PHONE --------------Solutions------------- WINAPI_PARTITION_APP and WINAPI_PARTITION_DESKTOP are t

  • VBA6 compiler constant in Word 2010 2013-10-31

    Is the "VBA6" compiler constant defined in Word 2010? I have the directive #If VBA6 = 0 Then .... #End If to run certain code in pre-2000 versions and I want to know whether this code will also be executed in Word 2010 (which I don't have an installe

  • VBA7 compiler constant usage 2014-01-26

    Bear with me ... have to step back a bit to explain where I'm coming from and why. Then the actual question. The name of the Win64 compiler constant strikes me as confusing. If it's true, you know you're running on a 64-bit version of Office, which n

  • Compiler constant indicating memory alignment requirement 2015-02-11

    Some CPU architectures (other than x86) dislike reading and writing multibyte numbers at unaligned addresses so much that they raise SIGBUS exception upon detecting this and forcing the programmer to do everything manually on a byte-wise order. While

  • Exclude complete namespace from FxCop code analysis? 2008-12-09

    Is it possible to exclude a complete namespace from all FxCop analysis while still analyzing the rest of the assembly using the SuppressMessageAttribute? In my current case, I have a bunch of classes generated by LINQ to SQL which cause a lot of FxCo

  • How to close the completion tooltip, without closing the compile output pane in QtCreator 2012-03-30

    When I'm writing code with QtCreator (2.4.1), I'm very often in this situation: something is wrong with my code, e.g a bad argument in a constructor. The error is reported in the compile output. Then I jump to the line to modify my code: once inside

  • Exclude folders from asp.net runtime compilation 2014-09-26

    I suspect that a project we've got running on Azure starts really slow due to asp.net runtime compilation iterating over 10.000 folders with media files even though it doesn't have to. Is there some way to tell the runtime compilation not to visit th

  • Using conditional compile constants to control JavaScript emitted by an MVC3 view 2011-07-24

    I have gleaned that it is possible to use conditional compiler directives and constants in Razor markup. I would like to know if there is a way to conditionally emit JavaScript text using these directives, as I seek to to below: @section BodyPanelScr

  • Visual Studio 2008 C# compiler const if statement problem! 2011-04-04

    When the following code in put in Visual Studio 2008 C#, The word "System" is underlined and is marked as "unreachable code": public static class Program { const int motors = 1; static void Main(string[] args) { if (motors < 1) { return; } System.

  • Compiling/Embedding ASCX templated UserControls for reuse in multiple web applications 2009-06-17

    I'm onto a real head scratcher here ... and it appears to be one of the more frustrating topics of ASP.NET. I've got an assembly that implements a-lot of custom Linq stuff, which at it's core has zero web functionality. I have an additional assembly

  • How to exclude work module from the compile, when deploying to GAE? 2009-09-08

    Our standard module file is: Myproject.gwt.xml We have added an extra modulefile for fast compilation called: MyprojectWork.gwt.xml When deploying to GAE, it compiles both Myproject.gwt.xml and MyprojectWork.gwt.xml. How to exclude MyprojectWork.gwt.

  • Exclude source file in compilation using Makefile 2012-04-23

    Is it possible to exclude a source file in the compilation process using wildcard function in a Makefile? Like have several source files, src/foo.cpp src/bar.cpp src/... Then in my makefile I have, SRC_FILES = $(wildcard src/*.cpp) But I want to excl

  • How to make the Visual Studio compiler ignore a file? 2009-03-05

    Is anyone aware of a way to make visual studio completely ignore a file when compiling? I have a C# solution that has a foo.config file that isn't really a standard config file - it's just a text file. During compiling VS grabs a hold of the file and

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.086 (s). 11 q(s)