Setting up a C# build with C# generated files

8 posts / 0 new
Last post
Offline
Last seen: 4 years 4 months ago
Joined: 07/01/2014
Posts: 9
Setting up a C# build with C# generated files

Hi,


I have used rtiddsgen -language C# to generate the interface files and I'm not quite sure how to get them assembled into .NET solution. 


I've got a C# Visualization project that contains:

- VisualizationService_publisher.cs

- VisualizationService_subscriber.cs

and a C++ DDS_Access.dll that includes:

- VisualizationService.h/cpp

- VisualizationServicePlugin.h/cpp

- VisualizationServiceSupport.h/cpp

 

However, when I try ot compile, I get an error C2871: 'DDS' : a namespace with this name does not exist. 

My compiler options are:  

/Od /I "C:\svn\PROJECT\trunk\DisplayForm\VisualizationService\DisplayForm\\DisplayForm\\DataAccess\DDS" /I "%NDDSHOME%\include" /I "%NDDSHOME%" /AI "%NDDSHOME%\include" /AI "%NDDSHOME%" /AI "%NDDSHOME%\lib\i86Win32VS2008" /D "WIN32" /D  "_DEBUG" /D "RTI_WIN32" /D "_UNICODE" /D "UNICODE" /D "_WINDLL" /FD /EHa /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /Zi /clr /TP /errorReport:prompt /FU "c:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll" /FU "c:\Windows\Microsoft.NET \Framework\v2.0.50727\System.Data.dll" /FU "c:\Windows\Microsoft.NET\Framework\v2.0.50727\System.XML.dll"

and my linker options are:

/OUT:"C:\svn\PROJECT\trunk\DisplayForm\VisualizationService\Make\..\lib\Debug\DDS_Access.dll" /INCREMENTAL /NOLOGO /DLL /MANIFEST /MANIFESTFILE:"Debug\DDS_Access.dll.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /ASSEMBLYDEBUG /PDB:"C:\svn\PROJECT\trunk\DisplayForm\VisualizationService\lib\Debug\DDS_Access.pdb" /DYNAMICBASE /FIXED:No /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT C:\svn\PROJECT\trunk\DisplayForm\VisualizationService\lib\Debug\MAINLINE_DDS.lib %NDDSHOME%\lib\i86Win32VS2008\nddscppzd.lib %NDDSHOME%\lib\i86Win32VS2008\nddsczd.lib %NDDSHOME%\lib\i86Win32VS2008\nddscorezd.lib Iphlpapi.lib ws2_32.lib

Thanks in advance!

Myca

Offline
Last seen: 3 years 1 month ago
Joined: 01/15/2013
Posts: 94

Hi Myca,

Just to make sure before anything else, I assume your NDDSHOME environment variable is correctly set to point to your current ndds.[version] installation (e.g. "C:\path-to-RTI-folter\ndds.[version]"). Is this the case?

Thanks,

Juanlu

Offline
Last seen: 5 years 8 months ago
Joined: 01/31/2011
Posts: 37

Hi Myca,

If you're building for C#, the library paths should be for i86Win32dotnet2.0 or i86Win32dotnet4.0, depending on the .Net framework.  Your paths show i86Win32VS2008, which only has libraries for C/C++.  In addition, you'll need to add the nddsdotnet.dll (or nddsdotnet40.dll) library to your compiler and linker options.  

There are example C# projects in the %NDDSHOME%\example\CSHARP directory.  Also, take a look at the Platform Notes doc (%NDDSHOME%\doc\pdf\RTI_CoreLibrariesAndUtilities_PlatformNotes) for build instructions on various platforms, including Windows C#.

 

Offline
Last seen: 4 years 4 months ago
Joined: 07/01/2014
Posts: 9

Thank you Juanlu and Sumeet.  I am looking at the examples directory now and I am having some trouble there, too.  In the HelloWorld_Type.sln, I am getting an error that NDDSHOME is not set.  I need to set it within the project file, so I am attempting to set it in Properties -> Debugging --> Environment like so:

NDDSHOME=c:\Program Files (x86)\RTI\ndds.4.5f


but it seems to be ignoring me.  How do you set NDDSHOME in the C++ solution? 

 

Also, when I run Hello_Simple.sln, I defined NDDSHOME in the Properties --> Setting and that seemed to take, but I get the following error:

------ Build started: Project: HelloPublisher, Configuration: Debug Any CPU ------
HelloPublisher -> C:\Users\Myca\Documents\CSHARP\Hello_simple\win32\obj\Debug\HelloPublisher.exe
copy "\lib\i86Win32dotnet2.0\*.dll"  "C:\Users\Myca\Documents\CSHARP\Hello_simple\win32\obj\Debug\"
The system cannot find the path specified.
C:\Windows\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(3109,13): error MSB3073: The command "copy "\lib\i86Win32dotnet2.0\*.dll"  "C:\Users\Michele\Documents\CSHARP\Hello_simple\win32\obj\Debug\"" exited with code 1.
Done building project "HelloPublisher.csproj" -- FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

Shouldn't it be interpretting NDDSHOME to copy those DLLs over? 

So basically, it seems like C++ and C# projects set the NDDSHOME environment differently and I'd like to understand how to set them in each. 

Thanks in advance,

Myca

Offline
Last seen: 3 years 1 month ago
Joined: 01/15/2013
Posts: 94

Hi Myca,

Make sure that you add quotes ("") in the paths containing spaces, I've had problems with that in the past. E.g. "C:\Program Files (x86)\RTI\ndds.4.5f".

Maybe that's what's causing both problems. Can you give this a try?

Offline
Last seen: 4 years 4 months ago
Joined: 07/01/2014
Posts: 9

Thank you Juanju.  I am just setting %NDDSHOME% globally for now to try to move forward.  I have confirmed it is set correctly because I can run the rtiddsgen command correctly using that global setting.  I have also fixed all of my paths to point to %NDDSHOME%/lib/x86Win32dotnet2.0, but I still get a compile error that namespace DDS is not found from one of my generated files and I am wondering if the files rtiddsgen generates aren't missing the includes they need to refer to the DDS namespace. 

Here is my latest compile input:

/Od /I "C:\svn\PROJECT\trunk\VisualizationService\DisplayForm\DisplayForm\DataAccess\DDS" /I "%NDDSHOME%\include" /I "%NDDSHOME%\" /I "C:\svn\MAINLINE\MAINLINE_DDS\trunk\DDS" /I "%NDDSHOME%\include\ndds" /AI "%NDDSHOME%\include" /AI "%NDDSHOME%\" /AI "c:\svn\MAINLINE\MAINLINE_DDS\trunk\DDS" /AI "%NDDSHOME%\lib\i86Win32dotnet2.0" /AI "%NDDSHOME%\include\ndds" /D "WIN32" /D "_DEBUG" /D "RTI_WIN32" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /FD /EHa /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /Zi /clr /TP /errorReport:prompt /FU "c:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll" /FU "c:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll" /FU "c:\Windows\Microsoft.NET\Framework\v2.0.50727\System.XML.dll"

When it told me the DDS namespace was undefined, I manually added "#include ndds\ndds_namespace_cpp.h" in the generated <idlTypes>.h file and that cleared up the error, but then it gave me other errors about "UserValueSequence" not being a member of DDS. I'm wondering if the generated files aren't generating the the #include statements they need from the DDS dlls?

Here is what the generated file looks like:

/*
  WARNING: THIS FILE IS AUTO-GENERATED. DO NOT MODIFY.

  This file was generated from UCSCoreTypes.idl using "rtiddsgen".
  The rtiddsgen tool is part of the RTI Connext distribution.
  For more information, type 'rtiddsgen -help' at a command shell
  or consult the RTI Connext manual.
*/
#include "ndds\ndds_namespace_cpp.h"   // Manually added after generation

#pragma once


struct DDS_TypeCode;
    

using namespace System;
using namespace DDS;

    
namespace MBA{

namespace Enumerations{


public enum class StatusEnum : System::Int32 {
    
    INITIATED_STATUS,
    COMPLETED_STATUS,
    FAILED_STATUS,
    IN_PROGRESS_STATUS
};



public ref class StatusEnumSeq
        : public DDS::UserValueSequence<StatusEnum> {   // Now that DDS is defined, UserValueSequence is not recognized as a member of DDS
public:
    EnumSeq() :
            DDS::UserValueSequence<StatusEnum>() {
        // empty
    }

};

 

Thanks again,

Myca

 

 

Offline
Last seen: 3 years 1 month ago
Joined: 01/15/2013
Posts: 94

Hi Myca,

Your case is quite strange, because the "using namespace DDS;" sentence in the generated code should access the C++/CLI DDS namespace for you. What I mean is, you shouldn't (and are discouraged to) modify the generated code files.

Would it be possible for you to share your project? Maybe I can try and build locally, and see if I can figure out what's wrong.

Thanks,

Juanlu

Offline
Last seen: 4 years 4 months ago
Joined: 07/01/2014
Posts: 9

Hi Juan,


I've gotten past the compile error by working through the example code in hello_idl.  I was missing a reference to the DDS_Acess library that holds my generated files. 


Thanks,

Myca