1

我的项目(VS 2005)中有一段代码使用Microsoft.Vsa命名空间。在编译时显示它已被弃用。在进一步调查中,我发现它在 VS2005 版本中不受支持。任何人都可以帮助我如何修改那段代码以使其适用于 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;
    }

}
4

0 回答 0