I have a piece of code in my project (VS 2005) which uses the Microsoft.Vsa
namespace. On compiling it shows it is deprecated. On investigating further, I found out it was not supported in the version VS2005. Can anybody help me how to modify that piece of code so that it works with VS 2005?
public class Mobile8ScriptEngine : Microsoft.Vsa.IVsaSite
{
private const string MODULENAME = "Mobile8ScriptEngine";
private IVsaEngine Engine;
private string MyMoniker = "myapp://uk.co.mdo/Mobile8ScriptEngine";
private byte[] Code = new byte[1024];
private IVsaItems Items;
//this method creates the script engine
public void CreateEngine()
{
try
{
Engine = new Microsoft.VisualBasic.Vsa.VsaEngine();
Engine.RootMoniker = MyMoniker;
Engine.Name = "aisland";
Engine.RootNamespace = "Mobile8";
Engine.Site = this;
Items = Engine.Items;
//adding the reference items
IVsaReferenceItem ReferenceItem = (IVsaReferenceItem)Items.CreateItem("Mobile8", Microsoft.Vsa.VsaItemType.Reference, Microsoft.Vsa.VsaItemFlag.None);
ReferenceItem.AssemblyName = "System.dll";
ReferenceItem.AssemblyName = "System.Xml.dll";
}
catch (Exception ex)
{
throw ex;
}
}
public string ExecuteVSAScript(string asMsgId, string asRefType, string asRefNo, string asHostMsg, string asMsgTypeScript, string asOutFormat)
{
const string PROCNAME = "ExecuteVSAScript";
LogExceptionMessage lObjExcepLog = new LogExceptionMessage();
SOURCE = MODULENAME + "." + PROCNAME;
string lsScriptCode = "", lsOutMsg = null, lsCombinedScript = "", lsScriptFilePath = "";
int liErrCode = 0;
StreamReader lobjStreamReader;
XmlDocument XMLDoc;
try
{
asHostMsg = asHostMsg.ToUpper();
//loading the host message in the XMLDocument
XMLDoc = new XmlDocument();
// XMLDoc.Load("Mobile8Config.xml");
// XmlNode lobjXmlNode= XMLDoc.SelectSingleNode("Configuration/CommonSettings/VSAScriptPath");
lsScriptFilePath = BUConstants.GetVSAScriptPath();
// lsScriptFilePath=lobjXmlNode.InnerText;
XMLDoc.LoadXml(asHostMsg);
//VSA script executon
lobjStreamReader = File.OpenText(lsScriptFilePath + " \\" + asMsgTypeScript);
lsScriptCode = lobjStreamReader.ReadToEnd();
lobjStreamReader.Close();
lsCombinedScript = scScriptStartCode + lsScriptCode + scScriptEndCode;
Mobile8ScriptEngine lobjVSAEngine = new Mobile8ScriptEngine();
lobjVSAEngine.CreateEngine();
lobjVSAEngine.RevokeCache();
bool lbCompilationStatus = lobjVSAEngine.AddScript(lsCombinedScript);
if (lbCompilationStatus)
{
object[] lobjScriptArgs ={ asRefType, asRefNo, XMLDoc, asOutFormat };
lobjVSAEngine.StartEngine();
lsOutMsg = lobjVSAEngine.ShowResult(lobjScriptArgs);
lobjVSAEngine.Close();
GC.Collect();
}
else//Error: Failed to compile the VSA script
{
liErrCode = 1079;
lObjExcepLog.LogMessage(1, null, liErrCode, scStatusSMSFormatFailed, asMsgId, 5, false, SOURCE);
}
}
catch (System.Data.DataException objDBException)
{
throw objDBException;
}
catch (System.Runtime.InteropServices.ExternalException objExtException)
{
throw objExtException;
}
catch (Exception objException)
{
throw objException;
}
return lsOutMsg;
}
}