|
Hi !
THanks for you answer. I know that the serializer stores each object only once. But thats not the idea behind my question, because in my graph there are CERTAIN objects that MUST NOT be serialized... This is because e.g high level objects are in the graph like the graphics renderer or sound engine, which can be different on other machines, but still the serialized files should be loadable. So i need the Iserializeable interface.
The code i sent in was just some dummy code, here is the REAL CODE now:
private Node ( SerializationInfo info, StreamingContext c )
{
m_children = new SortedList();
Debug.WriteLine("Deserializing object");
// And finally the node data itself.
m_reference = info.GetValue("WrappedObject",typeof(object) );
m_id = (Identifier)info.GetValue("Id",typeof(Identifier) );
Debug.WriteLine(m_id.Name,"Assigned key to");
// Add number of children
int numChildren = (int)info.GetValue( "ChildrenCount",typeof(int) );
// Serialize the child nodes first
for( int i = 0; i < numChildren; i++ )
{
// Generate an index key
string nodeName = "Node" + i;
Node newNode = (Node)info.GetValue(nodeName,typeof(Node) );
Attach( newNode );
}
// Now we store the parent reference.
if ( m_parentSerialize )
m_parent = (Node)info.GetValue("NodeParent",typeof(Node) );
}
///
/// Serialization method for nodes. This is required
/// so that the class tree does not get walked in the
/// wrong direction, since we want certain node wrapped
/// classes to be kept out of serialization.
///
/// <param name="info" />Serialization info.
/// <param name="context" />Serialization context.
public void GetObjectData( SerializationInfo info, StreamingContext context )
{
Debug.WriteLine(Id.Name,"GetObjectData called for");
// And finally the node data itself.
info.AddValue("WrappedObject",m_reference );
info.AddValue("Id",m_id,typeof(Identifier) );
// Add number of children
info.AddValue( "ChildrenCount",m_children.Count );
int index = 0;
// Serialize the child nodes first
foreach( Node n in m_children.Values )
{
// Generate an index ke
string nodeIndex = "Node" + index;
info.AddValue( nodeIndex,n,typeof(Node) );
index ++;
}
// Now we store the parent reference.
if ( m_parentSerialize )
info.AddValue("NodeParent",m_parent,typeof(Node) );
}
The problem now is that "Attach" adds the node to the SOrtedList representing the children with m_id as the key and the node as the value. HOWEVER i get the exception that the KEY is NULL all the time. I added some debug messages and it seems that a child node is added BEFORE it got an ID, so it is not complety reconstructed....
Any clues ?
|
|
|
|
|
What is the code for Attach, from what I can tell everything looks fine there; and how does m_id and newNode interact? I don't see anything that brings them together.
James
Simplicity Rules!
|
|
|
|
|
I could be off the mark here but couldn't you just let serialization happen naturally and mark the fields in the graph that you don't want serialized with [NonSerialized()]?
Regards
|
|
|
|
|
If you copy some code from a web page and try to paste it into an .aspx file in VC7 it usually inserts a bunch of bogus html tags. Is there a way to paste as plain text without the html tags?
<%@ Import Namespace="System.IO" %>
<SCRIPT LANGUAGE="C#"
RUNAT="SERVER">
should be
<%@ Import Namespace="System.IO" %>
</p>
If it's not built in, is there a way to do it via macro?
grrr
P.S. what tags do I use to prevent CP from eating characters such as > < < etc.?
|
|
|
|
|
Menu Edit - Paste as HTML ?
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
That works if it's an HTML file but not a .aspx file. Weird.
Todd Smith
|
|
|
|
|
Todd Smith wrote:
P.S. what tags do I use to prevent CP from eating characters such as > < < etc.?
CP isn't eating < and >, your web browser is. Replace < with < and replace > with >
James
Simplicity Rules!
|
|
|
|
|
|
Guys:
I am very new to .Net.
I have setup CDs of Visual Studio.Net Enterprise Architect. When I run the setup on Win 98, it says the OS should be at least Win NT4.0.
Will ME or XP OK?
|
|
|
|
|
Srini Kella wrote:
Will ME or XP OK?
XP is OK.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
The Framework (which is required for someone to run a .NET program) requires Windows 98 or later, or Windows NT 4.0 or later.
The SDK and Visual Studio .NET both require Windows NT 4.0 or later or Windows XP Professional.
James
Simplicity Rules!
|
|
|
|
|
And Windows NT4 must be SP6a.
Kevin
|
|
|
|
|
What is your %PATH% after installing .NET?
I was just reading through a .net book and they said to run ildasm.exe from start/run. Apparently I didn't have the proper path in my environment variable. Did something goof up during my install?
Todd Smith
|
|
|
|
|
As far as I know the path isn't set if you run the setup from VS.NET, but you are prompted to set the path if you install the SDK separately.
In anycase, add %WINDIR%\Microsoft.NET\[framework version]\ to your path.
James
Simplicity Rules!
|
|
|
|
|
I have the following method that instantiates a specified class in a given .NET assembley with specified activation attributes.
HRESULT LoadCORClassEx(
BSTR AssemblyName, /* mscorlib */
BSTR typeName, /* System.Text.RegularExpressions.Regex */
REFIID riid,
void **ppv,
SAFEARRAY *args)
{
HRESULT hr = S_OK;
if(ppv == NULL) return E_POINTER;
*ppv = 0;
/*** debug ***/
VARIANT var;
HRESULT hresult;
long ix = 0;
VariantInit(&var);
hresult = SafeArrayGetElement( args, &ix, &var);
if(FAILED(hresult)) return hresult;
/*** end debug ***/
CComPtr<_ObjectHandle> spHandle;
spHandle.p = g_host.spDefaultAppDomain->CreateInstance_2(
AssemblyName,
typeName,
args);
CComVariant unwrapped;
unwrapped = spHandle->Unwrap();
if (unwrapped.vt != VT_UNKNOWN && unwrapped.vt != VT_DISPATCH)
return E_UNEXPECTED;
return unwrapped.punkVal->QueryInterface(riid, ppv);
}
I can get the contents of the args SAFEARRAY that is passed into this method into a variant -- shown in the debugger as {"abc" VT_BSTR} -- before the subsequent call to CreateInstance_2(), however, when I step into the call to CreateInstance_2(), the underlying raw_CreateInstance_2() call in mscorlib.tli blows up .
Can anyone see what I am doing wrong here? I tried adding the save /*** debug ***/ code to mscorlib.tli in order to peek at the content of the SAFEARRAY being passed for activation attributes, but the debugger seems to ignore the added code...
Thanks for any insights!
--
Roy
|
|
|
|
|
Sometimes this may happen if you forgot to call SysAllocString to allocate the BSTR. Make sure that you are not doing anything like
VARIANT vt;
vt.vt = VT_BSTR;
vt.bstrVal = OLESTR("Test");
Check the same for other BSTR's
|
|
|
|
|
The code that creates the SAFEARRAY looks like the following:
HRESULT hRes;
VARIANT Placeholder;
LPCTSTR str = session->GetString((pbstring)(pbvArgs[i]->GetString( session )));
_bstr_t bstr_val( str );
Placeholder.bstrVal = SysAllocString( bstr_val );
hRes = SafeArrayPutElement( psaArgs, &Place, &Placeholder );
if (hRes != S_OK)
{
pbrRet = PBX_E_INVOKE_FAILURE;
}
VariantClear(&Placeholder);
The SAFEARRAY is then passed to another call:
LoadCORClassEx (bstr_1, bstr_2, IID_IUnknown, (void**)&pIDispatch, psaArgs);
Do you see anything else that I might be doing wrong?
Thanks,
Roy
|
|
|
|
|
Are you allocating the SAFEARRAY?
|
|
|
|
|
Yes, see code below:
SAFEARRAYBOUND sabArgs[1];
sabArgs[0].cElements = size;
sabArgs[0].lLbound = 0;
SAFEARRAY FAR* psaArgs = new SAFEARRAY;
psaArgs = SafeArrayCreate( VT_VARIANT, 1, sabArgs );
</p>
|
|
|
|
|
This is plain wrong. This is not the way you allocate a SAFEARRAY.
For creating 1 dimensional array use the following code
SAFEARRAY FAR* psaArgs =SafeArrayCreateVector(VT_VARIANT, 0, size);
Next call SafeArrayLockData
VARIANT* rgVtVals = NULL;
SafeArrayLockData(psaArgs, (VARIANT**)&rgVtVals);
Then start filling rgVtVals
Finally unlock
SafeArrayUnlockData(psaArgs);
|
|
|
|
|
I could not find references to SafeArrayLockData or SafeArrayUnlockData -- did you intend for me to use SafeArrayAccessData and SafeArrayUnaccessData? Those seem to match the parameters.
--
Thanks,
Roy
|
|
|
|
|
Sorry yes I mean SafeArrayAccessData and safeArrayUnaccessData
|
|
|
|
|
I'm trying to get the wrox book samples working on my system:
http://www.wrox.com/ACON12H4.asp?WROXEMPTOKEN=160192ZjePJD4tgkFUWWDBumUS&ISBN=1861005644
I tried this at home on XP and at work on 2K and both of my machines produce the same error.
I can't figure out if it's an IIS configuration problem or a code problem (is an assembly requred?)
Can anyone get these samples to work?
I get the following errors when trying to run the Chapter01\CompositeControl.aspx sample:
Server Error in '/aspsc' Application.
--------------------------------------------------------------------------------
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: File or assembly name CompositeControl, or one of its dependencies, was not found.
Source Error:
Line 1: <%@ Register TagPrefix="Custom" Namespace="CompositeControl" Assembly = "CompositeControl" %>
Line 2: <%@ Page Language="c#" Debug="true" %>
Line 3:
Source File: F:\alchdev\Professional ASP.NET Server Controls - Building Custom Controls with C#\Chapter01\CompositeControl.aspx Line: 1
Assembly Load Trace: The following information can be helpful to determine why the assembly 'CompositeControl' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = CompositeControl
(Partial)
LOG: Appbase = file:///F:/alchdev/Professional ASP.NET Server Controls - Building Custom Controls with C#
LOG: Initial PrivatePath = bin
Calling assembly : (Unknown).
===
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Post-policy reference: CompositeControl
LOG: Attempting download of new URL file:///D:/WINNT/Microsoft.NET/Framework/v1.0.3705/Temporary ASP.NET Files/aspsc/52a1ba08/5db97123/CompositeControl.DLL.
LOG: Attempting download of new URL file:///D:/WINNT/Microsoft.NET/Framework/v1.0.3705/Temporary ASP.NET Files/aspsc/52a1ba08/5db97123/CompositeControl/CompositeControl.DLL.
LOG: Attempting download of new URL file:///F:/alchdev/Professional ASP.NET Server Controls - Building Custom Controls with C#/bin/CompositeControl.DLL.
LOG: Attempting download of new URL file:///F:/alchdev/Professional ASP.NET Server Controls - Building Custom Controls with C#/bin/CompositeControl/CompositeControl.DLL.
LOG: Attempting download of new URL file:///D:/WINNT/Microsoft.NET/Framework/v1.0.3705/Temporary ASP.NET Files/aspsc/52a1ba08/5db97123/CompositeControl.EXE.
LOG: Attempting download of new URL file:///D:/WINNT/Microsoft.NET/Framework/v1.0.3705/Temporary ASP.NET Files/aspsc/52a1ba08/5db97123/CompositeControl/CompositeControl.EXE.
LOG: Attempting download of new URL file:///F:/alchdev/Professional ASP.NET Server Controls - Building Custom Controls with C#/bin/CompositeControl.EXE.
LOG: Attempting download of new URL file:///F:/alchdev/Professional ASP.NET Server Controls - Building Custom Controls with C#/bin/CompositeControl/CompositeControl.EXE.
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.0.3705.209; ASP.NET Version:1.0.3705.0
Todd Smith
|
|
|
|
|
I had my control in a subdirectory of the web root
\webroot\test\bin\mycontrol.dll
\webroot\test\mycontrol.aspx
That gave me the following error
File or assembly name MyControl, or one of its dependencies, was not found.
To fix it all I had to do was move the \bin dir to the root
\webroot\bin\mycontrol.dll
\webroot\test\mycontrol.aspx
and it worked!
Todd Smith
|
|
|
|
|
With all this emphesis on .NET and the internet. Why is there not class in the new .NET Framework to parse HTML tags?
|
|
|
|