Click here to Skip to main content
15,895,084 members
Home / Discussions / C#
   

C#

 
AnswerRe: Method Returns Twice Pin
Expert Coming3-Aug-06 20:27
Expert Coming3-Aug-06 20:27 
GeneralRe: Method Returns Twice Pin
Shajeel3-Aug-06 20:38
Shajeel3-Aug-06 20:38 
GeneralRe: Method Returns Twice [modified] Pin
lmoelleb3-Aug-06 20:44
lmoelleb3-Aug-06 20:44 
AnswerRe: Method Returns Twice Pin
Christian Graus3-Aug-06 20:52
protectorChristian Graus3-Aug-06 20:52 
GeneralRe: Method Returns Twice Pin
Expert Coming3-Aug-06 21:31
Expert Coming3-Aug-06 21:31 
GeneralRe: Method Returns Twice Pin
Guffa5-Aug-06 13:45
Guffa5-Aug-06 13:45 
AnswerRe: Method Returns Twice Pin
leppie3-Aug-06 21:30
leppie3-Aug-06 21:30 
QuestionProblem including C++ code in C# assembly Pin
OrcBighter23-Aug-06 15:49
OrcBighter23-Aug-06 15:49 
I have a problem setting a class constant in my C# assembly to the value of a constant in a managed C++ class. The compiler does not seem to recognise that the managed C++ class constant is constant. The error message is shown below:

#error = "The expression being assigned to 'MyAssembly.SMyFooBar.bahName' must be constant

What Have I done wrong here?


I am writing in Visual Studio 2003 on WinXP SP2 with .Net Framework V2.0.50727

The reason for this attempt is that the majority of our code is unmanaged c++, which uses a glabal header file to set values through a number of
projects.
I wish to include this header in our various new C# projects, and thus avoid double maintenance. If the header file changes, all that is needed is a code recompile, at least in theory.
To do this I wrapped the header file inside a managed c++ class to create a dll. I then included this dll as a reference in my C# project so that I
could use it to initialise some c# constants, thus:


-- unmanaged C++ header
// CPPHeader.h

#ifndef CPPHeader_defined_hpp
#define CPPHeader_defined_hpp

#define MAX_FOOBARS 3
#define FOOBAR_NAME "Foo Bar"

#endif // CPPHeader_defined_hpp


---------------------
-- managed C++ class

//MyManagedClass.h compiled to a DLL
#pragma once
#include "CPPheader.h"

using namespace System;

public __gc class SMyManagedClass
{
public:
static const int maxFooBars = MAX_FOOBARS;
static const String* FooBarName = FOOBAR_NAME;
};

--------------------------

-- C# assembly

//MyFooBarAsembly.cs
using system;
using SMyManagedClass;

namespace MyAssembly
{
public class SMyFooBar
{
public const int maxBahs = SMyManagedClass.SMyManagedClass.maxFooBars;
public const string bahName = SMyManagedClass.SMyManagedClass.FooBarName;
}
}



OrcBighter2
AnswerRe: Problem including C++ code in C# assembly Pin
Christian Graus3-Aug-06 16:31
protectorChristian Graus3-Aug-06 16:31 
QuestionCreate Combo Box In ListView in Pocket PC App. Pin
kakarato3-Aug-06 15:44
kakarato3-Aug-06 15:44 
QuestionFree Database for .NET Pin
Tyler453-Aug-06 15:22
Tyler453-Aug-06 15:22 
AnswerRe: Free Database for .NET Pin
Furty3-Aug-06 15:49
Furty3-Aug-06 15:49 
QuestionRe: Free Database for .NET Pin
Tyler453-Aug-06 15:53
Tyler453-Aug-06 15:53 
AnswerRe: Free Database for .NET Pin
Furty3-Aug-06 15:58
Furty3-Aug-06 15:58 
AnswerRe: Free Database for .NET Pin
Tyler453-Aug-06 16:01
Tyler453-Aug-06 16:01 
QuestionSimple(?) Generics question [modified] Pin
Furty3-Aug-06 15:10
Furty3-Aug-06 15:10 
AnswerRe: Simple(?) Generics question Pin
Christian Graus3-Aug-06 16:33
protectorChristian Graus3-Aug-06 16:33 
AnswerRe: Simple(?) Generics question Pin
leppie3-Aug-06 21:34
leppie3-Aug-06 21:34 
Questionprinting forms Pin
TWatson473-Aug-06 12:56
TWatson473-Aug-06 12:56 
AnswerRe: printing forms Pin
Not Active3-Aug-06 14:37
mentorNot Active3-Aug-06 14:37 
GeneralRe: printing forms Pin
TWatson474-Aug-06 4:50
TWatson474-Aug-06 4:50 
GeneralRe: printing forms Pin
Not Active4-Aug-06 6:01
mentorNot Active4-Aug-06 6:01 
AnswerRe: printing forms Pin
Vipin Venugopal3-Aug-06 17:53
Vipin Venugopal3-Aug-06 17:53 
GeneralRe: printing forms Pin
Not Active4-Aug-06 6:00
mentorNot Active4-Aug-06 6:00 
QuestionRegistry saving Vs. XML Saving Pin
Saamir3-Aug-06 11:59
Saamir3-Aug-06 11:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.