C3636 on value types 
Author Message
 C3636 on value types

Hi,
I have a managed class that contains a member variable of
value type Rectangle (System::Drawing). The managed class
uses Rectangle internally and does not expose it to the
outside world. I have a "#using <System.drawing.dll>"
inside my source file for this class. Everything compiles
well and my output dll is generated.
Now I want to create a Managed C++ application and create
an object of this class. If I do this using the new
operator inside the source file, which has a "#using
<Class.dll>" statement at the top, I get a C3636 error:
The type 'System::Drawing::Rectangle' is inaccessible or
undefined in 'System.Drawing'. I am forced to also have
a "#using <System.drawing.dll> in my source file that
uses my Class even though the Rectangle member is
internal to the Class.
This problem does not exist if I create a C# application
and add a reference to Class.dll. Everything works fine
in this case.
Is this a flaw in Managed C++? Any workarounds? I don't
want the users of my class library to know about the
internal dependencies of my class library.
Thanks,
Vasi


Tue, 22 Feb 2005 19:46:41 GMT  
 C3636 on value types
I am fairly confident this is because in C# you did not add the /noconfig
switch. If you don't specify that switch then the following response file
will be auto included:

# This file contains command-line options that the C#
# command line compiler (CSC) will process as part
# of every compilation, unless the "/noconfig" option
# is specified.

# Reference the common Framework libraries
/r:Accessibility.dll
/r:Microsoft.Vsa.dll
/r:System.Configuration.Install.dll
/r:System.Data.dll
/r:System.Design.dll
/r:System.DirectoryServices.dll
/r:System.dll
/r:System.Drawing.Design.dll
/r:System.Drawing.dll
/r:System.EnterpriseServices.dll
/r:System.Management.dll
/r:System.Messaging.dll
/r:System.Runtime.Remoting.dll
/r:System.Runtime.Serialization.Formatters.Soap.dll
/r:System.Security.dll
/r:System.ServiceProcess.dll
/r:System.Web.dll
/r:System.Web.RegularExpressions.dll
/r:System.Web.Services.dll
/r:System.Windows.Forms.Dll
/r:System.XML.dll

As you can see System.Drawing .Dll is part of this list. Can you try and add
this switch to your C# compilation and see whether you get the same results
as MC++ then?

The runtime path for dependencies and the compile time path are completely
distinct. There is no compile time way to get from an assembly name (which
is what is in the meta data contains) to an assembly url (which is what the
compiler needs).

Ronald Laeremans
Visual C++ compiler and libraries team


Quote:
> Hi,
> I have a managed class that contains a member variable of
> value type Rectangle (System::Drawing). The managed class
> uses Rectangle internally and does not expose it to the
> outside world. I have a "#using <System.drawing.dll>"
> inside my source file for this class. Everything compiles
> well and my output dll is generated.
> Now I want to create a Managed C++ application and create
> an object of this class. If I do this using the new
> operator inside the source file, which has a "#using
> <Class.dll>" statement at the top, I get a C3636 error:
> The type 'System::Drawing::Rectangle' is inaccessible or
> undefined in 'System.Drawing'. I am forced to also have
> a "#using <System.drawing.dll> in my source file that
> uses my Class even though the Rectangle member is
> internal to the Class.
> This problem does not exist if I create a C# application
> and add a reference to Class.dll. Everything works fine
> in this case.
> Is this a flaw in Managed C++? Any workarounds? I don't
> want the users of my class library to know about the
> internal dependencies of my class library.
> Thanks,
> Vasi



Wed, 23 Feb 2005 02:27:20 GMT  
 C3636 on value types
Hi,
You are correct. It was the /noconfig option. I was also
able to get it to work by declaring the value types as
private and exposing them via properties to the derived
classes. I am not sure why this worked.
Vasi

Quote:
>-----Original Message-----
>I am fairly confident this is because in C# you did not
add the /noconfig
>switch. If you don't specify that switch then the

following response file
Quote:
>will be auto included:

># This file contains command-line options that the C#
># command line compiler (CSC) will process as part
># of every compilation, unless the "/noconfig" option
># is specified.

># Reference the common Framework libraries
>/r:Accessibility.dll
>/r:Microsoft.Vsa.dll
>/r:System.Configuration.Install.dll
>/r:System.Data.dll
>/r:System.Design.dll
>/r:System.DirectoryServices.dll
>/r:System.dll
>/r:System.Drawing.Design.dll
>/r:System.Drawing.dll
>/r:System.EnterpriseServices.dll
>/r:System.Management.dll
>/r:System.Messaging.dll
>/r:System.Runtime.Remoting.dll
>/r:System.Runtime.Serialization.Formatters.Soap.dll
>/r:System.Security.dll
>/r:System.ServiceProcess.dll
>/r:System.Web.dll
>/r:System.Web.RegularExpressions.dll
>/r:System.Web.Services.dll
>/r:System.Windows.Forms.Dll
>/r:System.XML.dll

>As you can see System.Drawing .Dll is part of this list.
Can you try and add
>this switch to your C# compilation and see whether you

get the same results
Quote:
>as MC++ then?

>The runtime path for dependencies and the compile time
path are completely
>distinct. There is no compile time way to get from an

assembly name (which

- Show quoted text -

Quote:
>is what is in the meta data contains) to an assembly url
(which is what the
>compiler needs).

>Ronald Laeremans
>Visual C++ compiler and libraries team



>> Hi,
>> I have a managed class that contains a member variable
of
>> value type Rectangle (System::Drawing). The managed
class
>> uses Rectangle internally and does not expose it to the
>> outside world. I have a "#using <System.drawing.dll>"
>> inside my source file for this class. Everything
compiles
>> well and my output dll is generated.
>> Now I want to create a Managed C++ application and
create
>> an object of this class. If I do this using the new
>> operator inside the source file, which has a "#using
>> <Class.dll>" statement at the top, I get a C3636 error:
>> The type 'System::Drawing::Rectangle' is inaccessible
or
>> undefined in 'System.Drawing'. I am forced to also have
>> a "#using <System.drawing.dll> in my source file that
>> uses my Class even though the Rectangle member is
>> internal to the Class.
>> This problem does not exist if I create a C#
application
>> and add a reference to Class.dll. Everything works fine
>> in this case.
>> Is this a flaw in Managed C++? Any workarounds? I don't
>> want the users of my class library to know about the
>> internal dependencies of my class library.
>> Thanks,
>> Vasi

>.



Wed, 23 Feb 2005 21:29:23 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. value types assigned to reference type

2. Initializing value type that contains reference type

3. value types vs. reference types

4. reference types in value types

5. managed value types

6. Question about value and reference types

7. Compilation error - __gc type cannot be passed by value

8. value type confusion

9. Visual C++.NET: Boxing Value Types in Managed C++

10. deterministic destructor of value type

11. Getting the return value type from a MethodBase

12. Default Value in a Strongly Typed DataSet

 

 
Powered by phpBB® Forum Software