473,396 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Cannot pass %s as ref or out, because %s is a marshal-by-reference class

Max
public class Entity : System.Windows.Forms.Label
{
....
protected System.Drawing.Point lastMousePosition;
....
}

public class Flow : Entity
{
....
protected override void OnMouseMove( System.Windows.Forms.MouseEventArgs
e )
{
int deltaX = MousePosition.X - lastMousePosition.X;
int deltaY = MousePosition.Y - lastMousePosition.Y;
...
}
....
}

This code causes an error:

Cannot pass ...lastMousePosition as ref or out, because ...lastMousePosition
is a marshal-by-reference class

What does it mean? What is wrong with the code?

Nov 15 '05 #1
4 2298
Max
The problem is solved by adding

protected System.Drawing.Size Delta
{
get
{
return new
System.Drawing.Size(MousePosition.X-lastMousePosition.X,MousePosition.Y-last
MousePosition.Y);
}
}

to Entity class and using this property in Flow.OnMouseMove.

But I still do not understanf what was wrong with the code as it was?
"Max" <Pl****@reply.to.news.group> wrote in message
news:uH****************@tk2msftngp13.phx.gbl...
public class Entity : System.Windows.Forms.Label
{
...
protected System.Drawing.Point lastMousePosition;
...
}

public class Flow : Entity
{
...
protected override void OnMouseMove( System.Windows.Forms.MouseEventArgs e )
{
int deltaX = MousePosition.X - lastMousePosition.X;
int deltaY = MousePosition.Y - lastMousePosition.Y;
...
}
...
}

This code causes an error:

Cannot pass ...lastMousePosition as ref or out, because ....lastMousePosition is a marshal-by-reference class

What does it mean? What is wrong with the code?

Nov 15 '05 #2
Hi Max,

I am not if I am missing something from your code snippet that could cause
the error, but I seem to be able to compile the same code correctly - The
compiler does not seem to complain if I use the below code snippets that you
posted.

public class Entity : System.Windows.Forms.Label
{
protected System.Drawing.Point lastMousePosition;
}

public class Flow : Entity
{
protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
{
int deltaX = MousePosition.X - lastMousePosition.X;
int deltaY = MousePosition.Y - lastMousePosition.Y;
}
}

Let me know and we can look into the issue a little more.

Regards,
Aravind C
"Max" <Pl****@reply.to.news.group> wrote in message
news:uH**************@tk2msftngp13.phx.gbl...
public class Entity : System.Windows.Forms.Label
{
...
protected System.Drawing.Point lastMousePosition;
...
}

public class Flow : Entity
{
...
protected override void OnMouseMove( System.Windows.Forms.MouseEventArgs e )
{
int deltaX = MousePosition.X - lastMousePosition.X;
int deltaY = MousePosition.Y - lastMousePosition.Y;
...
}
...
}

This code causes an error:

Cannot pass ...lastMousePosition as ref or out, because ....lastMousePosition is a marshal-by-reference class

What does it mean? What is wrong with the code?

Nov 15 '05 #3
Max
Thank you for trying.

Probably it depends on the version of Visual Studio or .NET framework.
I am using Visual Studio 2002 (and framework 1.0) and you?
I did not check it in framework 1.1.

Anyway, by now the problem is "academic" only. I've just rewritten the code
in another way and got rid of the error.
"Aravind C" <ar***********@nospam.hotmail.com> wrote in message
news:eo**************@TK2MSFTNGP12.phx.gbl...
Hi Max,

I am not if I am missing something from your code snippet that could cause
the error, but I seem to be able to compile the same code correctly - The
compiler does not seem to complain if I use the below code snippets that you posted.

public class Entity : System.Windows.Forms.Label
{
protected System.Drawing.Point lastMousePosition;
}

public class Flow : Entity
{
protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e) {
int deltaX = MousePosition.X - lastMousePosition.X;
int deltaY = MousePosition.Y - lastMousePosition.Y;
}
}

Let me know and we can look into the issue a little more.

Regards,
Aravind C
"Max" <Pl****@reply.to.news.group> wrote in message
news:uH**************@tk2msftngp13.phx.gbl...
public class Entity : System.Windows.Forms.Label
{
...
protected System.Drawing.Point lastMousePosition;
...
}

public class Flow : Entity
{
...
protected override void OnMouseMove(

System.Windows.Forms.MouseEventArgs
e )
{
int deltaX = MousePosition.X - lastMousePosition.X;
int deltaY = MousePosition.Y - lastMousePosition.Y;
...
}
...
}

This code causes an error:

Cannot pass ...lastMousePosition as ref or out, because

...lastMousePosition
is a marshal-by-reference class

What does it mean? What is wrong with the code?


Nov 15 '05 #4
Hi Max,

Yes, that could possibly be a reason.
I am on .NET 1.1.

Regards,
Aravind C
"Max" <Pl****@reply.to.news.group> wrote in message
news:eM**************@TK2MSFTNGP12.phx.gbl...
Thank you for trying.

Probably it depends on the version of Visual Studio or .NET framework.
I am using Visual Studio 2002 (and framework 1.0) and you?
I did not check it in framework 1.1.

Anyway, by now the problem is "academic" only. I've just rewritten the code in another way and got rid of the error.
"Aravind C" <ar***********@nospam.hotmail.com> wrote in message
news:eo**************@TK2MSFTNGP12.phx.gbl...
Hi Max,

I am not if I am missing something from your code snippet that could cause the error, but I seem to be able to compile the same code correctly - The compiler does not seem to complain if I use the below code snippets that you
posted.

public class Entity : System.Windows.Forms.Label
{
protected System.Drawing.Point lastMousePosition;
}

public class Flow : Entity
{
protected override void

OnMouseMove(System.Windows.Forms.MouseEventArgs e)
{
int deltaX = MousePosition.X - lastMousePosition.X;
int deltaY = MousePosition.Y - lastMousePosition.Y;
}
}

Let me know and we can look into the issue a little more.

Regards,
Aravind C
"Max" <Pl****@reply.to.news.group> wrote in message
news:uH**************@tk2msftngp13.phx.gbl...
public class Entity : System.Windows.Forms.Label
{
...
protected System.Drawing.Point lastMousePosition;
...
}

public class Flow : Entity
{
...
protected override void OnMouseMove(

System.Windows.Forms.MouseEventArgs
e )
{
int deltaX = MousePosition.X - lastMousePosition.X;
int deltaY = MousePosition.Y - lastMousePosition.Y;
...
}
...
}

This code causes an error:

Cannot pass ...lastMousePosition as ref or out, because

...lastMousePosition
is a marshal-by-reference class

What does it mean? What is wrong with the code?



Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: William Stacey | last post by:
The following code works, but I can't figure out why. I take a struct with two members, a single byte and byte. I then marshal the whole struct to a byte. I create a new struct (without init'ing...
3
by: J | last post by:
I'm at a loss on how to accomplish one item with C# entirely in managed code -- I'd like to make a call to a Win32 function, one of its parameters is a structure that contains a pointer to one or...
1
by: wbaccay | last post by:
I have a byte of binary data received from a NetworkStream (C# code) that I need to pass to the IWMWriter object in a DLL written in Managed extensions for C++ (since the Windows Media SDK is not...
7
by: Klaus Bonadt | last post by:
I have an existing VC6 application using the MFC. I am able to pass CString and other parameters from such a VC6 dll to an unmanaged MFC dll (compiled in Visual Studio .NET). Now I want to use...
12
by: glutz7878 | last post by:
I have no trouble passing __delegate ptrs to native C functions in DLLs, however when attempting to pass the __delegate ptr to a native C++ function in a DLL I get the following runtime exception:...
6
by: vladislavf | last post by:
Hi All, I need to pass array of strings from C++/CLI to unmanaged C++ function. (The unmanaged API signatire is : int Combine(int NumOfInputFiles, wchar_t **names) and I want to call it from...
0
by: shengmin.ruan | last post by:
i got a struct like: --------------------- public ref struct OutPacket{ int m_replyIndex; List<MainInfo^>^ m_mainInfos; }; --------------------- when i pass it to another process, i have...
0
by: Madhu_TN | last post by:
Hi All, I am new to this board. I am trying to create a Crystal Report viewer into a VS C++ Dot NET 2003 app ( This uses both managed and unmanaged code). I get the following compilation error:...
5
by: Anurag | last post by:
I have been chasing a problem in my code since hours and it bolis down to this import marshal marshal.dumps(str(123)) != marshal.dumps(str("123")) Can someone please tell me why? when...
3
by: michelqa | last post by:
Hi, I already post a similar question last week without success. Ok I want to get the current text selection in a RICHEDIT control.. This can be easily done in C++ with EM_EXGETSEL message. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.