.NETGURU
Regsvcs error : Specified cast is not valid.
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.component_services.

Post a new message to this list...

Jim Hsu
it's pretty strange that I will alwasy get an error when using RegSvcs to
register a Serviced Components.

the error is

The following installation error occurred:
1: An unknown error occurred while configuring components.
2: Specified cast is not valid.

code below:

#region Class Attribute for each AA should be modified

[ClassInterface(ClassInterfaceType.AutoDual),

GuidAttribute("28B8558E-EC80-4f32-9595-81783DB5BDB3"),

ProgId("CDPC.Bnkn1"),

Transaction(TransactionOption.Supported),

EventTrackingEnabled(true),

ObjectPooling(Enabled=true,MinPoolSize=0,MaxPoolSize=6),

ComVisible(true),

JustInTimeActivation(true)

]

#endregion Class Attribute for each AA should be modified

public class CdpcBnkn: ServicedComponent, IAdapter

{

static readonly LogPack logger = LogPack.GetLogger(typeof(CdpcBnkn));

protected string sProcCode = "CdpcBnkn";

[ComVisible(true)]

public string ProcCode

{

get{ return sProcCode ;}

set{ sProcCode = value;}

}

public CdpcBnkn()

{

logger.Debug("Constructed");

}

public bool bConnected = false;

public bool IsConnected

{

get{ return bConnected; }

}

[ComVisible(true)]

public string SendReceive(string request)

{

DateTime dt1 = DateTime.Now;

logger.Debug("SendReceive( string ) --> request == \n" + request);

//ContextUtil.DeactivateOnReturn = true;

try

{

#region CdpcBnknRq

CdpcBnknRq bnknRq1 = new CdpcBnknRq();

bnknRq1.RqUid = Guid.NewGuid().ToString();

/// need to geneate the STAN by SerialNoMgr

Srnoman srnoman1 = new Srnoman();

srnoman1.bluestarDBConn = const1.BlueStarDBConnectionString;

string stan1 = "0000000";

try

{

stan1 = srnoman1.sNextSerialNo( const1.SerialNoTask);

}

catch(Exception e)

{

logger.Error("SerialNoMgr error on task " + const1.SerialNoTask, e,
gac.SerialNoMgrError);

}

logger.Debug("using Stan " + stan1);

bnknRq1.STAN = stan1;

bnknRq1.TrnStartDateTime = DateTime.Now.ToString("yyyyMMddhhmmss");

if (this.ProcCode != "BNKN")

{

bnknRq1.ProcCode = "BNKN";

}

else

{

bnknRq1.ProcCode = "BNKF";

}

logger.Info("ProcCode is now " + bnknRq1.ProcCode);

#endregion CdpcBnknRq

#region Serialize CdpcBnknRq

//XmlDocument xd1 = new XmlDocument();

//XmlNodeWriter nodeWriter1 = new XmlNodeWriter(xd1, true);

StringBuilder builder1 = new StringBuilder();

StringWriter sw1 = new StringWriter(builder1);

XmlTextWriter writer1 = new XmlTextWriter( sw1);

XmlSerializer cdpcSerializer = new
XmlSerializer(typeof(CdpcBnknRq),const1.BlueStarNamesapce);

//StringBuilder builder1 = new StringBuilder();

//XmlTextWriter writer1 = new XmlTextWriter( new StringWriter(build1));

//writer1.Formatting = Formatting.Indented;

XmlSerializerNamespaces namespaces1 = new XmlSerializerNamespaces();

namespaces1.Add("", const1.BlueStarNamesapce);

//cdpcSerializer.Serialize( nodeWriter1, bnknRq1);

cdpcSerializer.Serialize( writer1, bnknRq1, namespaces1);

//'nodeWriter1.Flush();

//'nodeWriter1.Close();

writer1.Close();

logger.Debug("Bnkn Request is " + builder1.ToString());

#endregion Serialize CdpcBnknRq

WSMsgHandler.MsgHandler ws1 = new WSMsgHandler.MsgHandler();

ws1.Url = const1.WebSerivceUrl;

ws1.Timeout = const1.WebSerivceTimeOutMiniSec;

//XmlElement responseElement;

string sResponse;

int nWsRet = ws1.SubmitXmlString( builder1.ToString(), out sResponse );

logger.Info(" ** respose is " + sResponse);

StatusMan sman1 = new StatusMan();

sman1.connectionString = const1.BlueStarDBConnectionString;

BlueStarError bluestarStatus1;

bool bMapped = false;

if (nWsRet != 0)

{

//string sStatusCode,sSeverity, sStatusDesc;

//bMapped = sman1.StatusMap( const1.BlueStarStatusSource, nWsRet,
responseElement, out xeMapped, out sStatusCode,

// out sSeverity, out sStatusDesc );

bMapped = sman1.StatusMap("BlueStar", nWsRet.ToString(), out
bluestarStatus1);

if ( bMapped )

{

logger.Info("Mapped Status is " + bluestarStatus1.StatusCode + ", severity =
" +

bluestarStatus1.Severity +

" , StatusDesc = " + bluestarStatus1.StatusDesc );

}

//bluestarStatus1 = new BlueStarError(bnknRq1.MsgName, sStatusCode
,sSeverity ,sStatusDesc);

logger.Info("msgName is " + bluestarStatus1.MsgName );

bluestarStatus1.RqUid = bnknRq1.RqUid ;

bConnected = false;

}

else

{

#region deserialize the bnknRq1

cdpcSerializer = null;

cdpcSerializer = new XmlSerializer(typeof(CdpcBnknRs),
const1.BlueStarNamesapce);

//XmlNodeReader nodeReader1 = new XmlNodeReader(responseElement);

StringReader sr1 = new StringReader( sResponse);

//NameTable nt1 = new NameTable();

XmlTextReader reader1 = new XmlTextReader(sr1);

CdpcBnknRs bnknRs1 = new CdpcBnknRs();

bnknRs1 = ( CdpcBnknRs ) cdpcSerializer.Deserialize(reader1);

logger.Debug(" response = " + bnknRs1.data );

#endregion Deserialize the bnknRq1

bConnected = true;

}

DateTime dt2 = DateTime.Now;

TimeSpan ts1 = dt2.Subtract(dt1);

logger.Info("-------------- Transaction TimeSpan = " + ts1.ToString());

//return responseElement.OuterXml;

logger.Info("response is " + sResponse);

return sResponse;

}

catch(Exception e)

{

logger.Error( "AA error", e, CbfxStatus.AAError);

return e.ToString();

}

}

[ComVisible(true)]

[AutoComplete(true)]

public string SendReceiveX(string request)

{

return string.Empty;

}

}

Reply to this message...
 
    
Jim Hsu
solved. use property intead of attribute,...
strange. I don't remember that was on the document....
appreicate if anyone can provide a document link...

thx
jim

"Jim Hsu" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.DateTime
System.EnterpriseServices.ContextUtil
System.EnterpriseServices.ServicedComponent
System.EnterpriseServices.TransactionOption
System.Guid
System.IO.StringReader
System.IO.StringWriter
System.Runtime.InteropServices.ClassInterfaceType
System.Runtime.InteropServices.GuidAttribute
System.Text.StringBuilder
System.TimeSpan
System.Xml.Formatting
System.Xml.NameTable
System.Xml.Serialization.XmlSerializer
System.Xml.Serialization.XmlSerializerNamespaces
System.Xml.XmlDocument
System.Xml.XmlElement
System.Xml.XmlNodeReader
System.Xml.XmlTextReader
System.Xml.XmlTextWriter




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification