Comments (6)
But an IntPtr is simply a struct that points to that address. So isn't cloning the IntPtr as simple as creating a new IntPtr that points to the same address? The question of "what" is at that address shouldn't be relevant to the cloning process.
from deepcloner.
It can be problematic on Windows due use of native handles, which are problematic to clone. When you dispose one object, it closes native handle, so, other object stops to work. And in different classes - different policy for using native resources. I do not found way to make correct work for these types in any situation.
May be I'll try to make something with this type. Can you describe, which effects on Font
clone occur?
from deepcloner.
The solution is to identify the type and re-new a new object. It would solve away most of the problem, I'm not familiar with whether DeepCloner has a special tool to handle this. So if my class involves related objects, I would consider writing deep copies and using DeepCloner for other objects to solve it.
from deepcloner.
I'm having a similar problem cloning an Exception that includes an IntPtr in the TargetSite property. Is it possible to have DeepCloner ignore certain properties in Exception such as TargetSite?
from deepcloner.
Every IntPtr is a problem. In dotnet it simply native int (long/int depends on architecture). But it points to some unmanaged resource. And when we clone object - two object begun to own this resource and use it. But they do no not know about each other and can release it or do something other that will cause an error.
If DeepCloner will not copy IntPtr (e.g. set it to 0) - second object can throw NullPointerException but in some native way.
Some handles can be safely cloned, but other is impossible for this operation.
As result, it is very serious problem, and I do not know, what I can do with this globally.
from deepcloner.
Intptr is just a pointer, essentially just a nint. You only need to copy its value to the new nint/IntPtr structure like nint.
from deepcloner.
Related Issues (20)
- This exception is occasionally thrown in clones βmust be writeable (Parameter 'left')β HOT 4
- Request for info (country of origin) HOT 4
- HashSet contains method return false after deep clone HOT 8
- Support for cloning child to parent type HOT 2
- the program crashed when i deepclone opencvsahrp Mat HOT 3
- How to only clone the common properties? HOT 4
- Latest change has not been published to NuGet HOT 1
- Why version 0.X? HOT 3
- Exception: An instance of the __ComObject type cannot be created unless the type has been obtained using GetTypeFromProgID or GetTypeFromCLSID. HOT 4
- program crashed when deepclone multidimensional zero-length array HOT 1
- Dependency on BinaryFormatter? HOT 1
- Possible Heap Corruption and Garbage Collection Interference... HOT 4
- When Object have navigation property, DeepClone throw exception. HOT 5
- Better error reporting HOT 1
- Memory corruption and program crash when cloning TaskCancelledException
- NHibernate Invalid cast exception
- Can't clone dictionary HOT 4
- Clone Action<T> delegate is incorrect
- Netstandard upgrade HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deepcloner.