472,353 Members | 1,328 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Marshal a class partially


Is is possible to mark a class-member-variable to avoid its marshaling?

class MyClass
int i_;
IntPtr point_;

object obj; // this should not be marshaled


Nov 24 '05 #1
4 1468
Use [NotSerialized] attribute.

Nov 24 '05 #2
Thanks Tasos

but testing your suggestion with the following code it seems wrong:


using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace NotMarshal
class Program
struct MyStruct
int i;
int j;
int k;

struct MyStruct1
int i;
int j;
int k;

struct MyStruct2
int i;
int k;

static void Main(string[] args)
System.Console.WriteLine("SizeOf " + typeof(MyStruct).Name
+ " = " + Marshal.SizeOf(typeof(MyStruct)));
System.Console.WriteLine("SizeOf " + typeof(MyStruct1).Name
+ " = " + Marshal.SizeOf(typeof(MyStruct1)));
System.Console.WriteLine("SizeOf " + typeof(MyStruct2).Name
+ " = " + Marshal.SizeOf(typeof(MyStruct2)));

// output

SizeOf MyStruct = 12
SizeOf MyStruct1 = 12
SizeOf MyStruct2 = 8

sizeof MyStruct1 has to be 8.

Nov 24 '05 #3
>Is is possible to mark a class-member-variable to avoid its marshaling?

No. Can't you just separate the members to different types?

Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 24 '05 #4
it's what I did.


Nov 25 '05 #5

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

Similar topics

by: syd | last post by:
Hello all, In my project, I have container classes holding lists of item classes. For example, a container class myLibrary might hold a list of...
by: Lionel B | last post by:
Greetings. The following code compiles ok and does what I'd expect it to do: ---------- START CODE ---------- // test.cpp
by: Angel | last post by:
Hi again, I'm trying to call functions from a proprietary DLL but it's turned out to be more difficult than I thought. I have this W32.DLL which...
by: SB | last post by:
I feel dumb to ask because I bet this is a simple question... Looking at the code below, can someone please explain why I get two different...
by: dhornyak | last post by:
I have been banging my head against the wall for a while now, and can't seem to id the problem. I've been through a ton of posts and the code...
by: william.thorpe.b | last post by:
I have recently switched from VS2003 to VS2005 and at the same time from V1 to V2 of the .NET Compact Framework. The target is a Windows CE 5.0...
by: Rahul | last post by:
Hi, Is there a way to partially specialize only a member function of a template class (not the whole class). e.g. template <typename A,...
by: O.B. | last post by:
When using Marshal to copy data from a byte array to the structure below, only the first byte of the "other" array is getting copied from the...
by: xrxst32 | last post by:
Hello there, I have some doubts about the best practice for using COM automation, the Runtime Callable Wrapper (RCW) and Marshal.ReleaseComObject....
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

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.