HighTechTalks DotNet Forums  

C# seems not to understand pointer any more

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss C# seems not to understand pointer any more in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Peter
 
Posts: n/a

Default C# seems not to understand pointer any more - 12-14-2007 , 10:29 AM






We have code like this in our managed wrapper (written with managed
extensions in C++)

Byte * some_method();

which we compile with VS2003 to a managed assembly.

The functions in the assembly work nicely with C#/VB programs written with
VS2003, allowing unsafe code.

However, as soon as VS2005 is used to access these functions, the C#
compiler issues an error message of the kind that the language would not
support this construct.

Does anybody know what is going on here? Is this an issue with C# 2.0? How
can this be fixed?

Thanks.
Peter



Reply With Quote
  #2  
Old   
Willy Denoyette [MVP]
 
Posts: n/a

Default Re: C# seems not to understand pointer any more - 12-14-2007 , 11:09 AM






"Peter" <p.schregle (AT) impuls-imaging (DOT) com> wrote

Quote:
We have code like this in our managed wrapper (written with managed
extensions in C++)

Byte * some_method();

which we compile with VS2003 to a managed assembly.

The functions in the assembly work nicely with C#/VB programs written with
VS2003, allowing unsafe code.

However, as soon as VS2005 is used to access these functions, the C#
compiler issues an error message of the kind that the language would not
support this construct.

Does anybody know what is going on here? Is this an issue with C# 2.0? How
can this be fixed?

Thanks.
Peter



Please post the exact error message, it's not possible that the C# compiler
would show an error for a C++ module which isn't even compiled by the C#
compiler.
Not sure what you mean with "C#/VB programs written with VS2003, allowing
unsafe code." though, VB does not support unsafe code.


Willy.



Reply With Quote
  #3  
Old   
Peter
 
Posts: n/a

Default Re: C# seems not to understand pointer any more - 12-16-2007 , 06:50 AM



I'm sorry, I was a bit unclear in my description.

1) We create an assembly with Managed Extensions for C++ named
some_name.dll. This assembly has source code like the following

Byte * some_method() // a method returning a pointer, defined within some
class
{
....
}

This assembly is created with VS2003, i.e. it is a .NET 1.1 assembly.

2) We then create an application in C# using the assembly of step 1. In this
application we try to use some_method from the assembly. When we compile
this application with C# in VS2003 everything is fine: the C# compiler
issues no error message and the function works as expected when executed.

3) When we compile the same C# code with C# in VS2005, the compiler issues
the error message: "language does not support this construct". Using other
methods which do not use pointers from the same assembly still works
properly.

I hope the desciption is clearer now.

Clearly something must have changed between C#/VS2003 and C#/VS2005 with
regards to using pointers. It would be instructive to know what has been
changed. Furthermore, how can the issue be dealt with and worked around?

Peter







Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.