"景先生毕设|www.jxszl.com

C# CodeCompileUnit类代码示例

2023-12-29 17:45编辑: www.jxszl.com景先生毕设
本文整理汇总了C#中CodeCompileUnit类的典型用法代码示例。如果您正苦于以下问题:C#CodeCompileUnit类的具体用法?C#CodeCompileUnit怎么用?C#CodeCompileUnit使用的例子?这里精选的类代码示例或许可以为您提供帮助。 示例1:CreateWebServiceFromWsdl objectCreateWebServiceFromWsdl(byte[]wsdl){ //generateCodeDomfromWSDL ServiceDescriptionsd=ServiceDescription.Read(newMemoryStream(wsdl)); ServiceDescriptionImporterimporter=newServiceDescriptionImporter(); importer.ServiceDescriptions.Add(sd); CodeCompileUnitcodeCompileUnit=newCodeCompileUnit(); CodeNamespacecodeNamespace=newCodeNamespace(""); codeCompileUnit.Namespaces.Add(codeNamespace); importer.CodeGenerationOptions=CodeGenerationOptions.GenerateNewAsync|CodeGenerationOptions.GenerateOldAsync; importer.Import(codeNamespace,codeCompileUnit); //updatewebserviceproxyCodeDomtreetoadddynamicsupport stringwsProxyTypeName=FindProxyTypeAndAugmentCodeDom(codeNamespace); //compileCodeDomtreeintoanAssembly CodeDomProviderprovider=CodeDomProvider.CreateProvider("CS"); CompilerParameterscompilerParams=newCompilerParameters(); compilerParams.GenerateInMemory=true; compilerParams.IncludeDebugInformation=false; compilerParams.ReferencedAssemblies.Add(typeof(Ops).Assembly.Location);//DLR CompilerResultsresults=provider.CompileAssemblyFromDom(compilerParams,codeCompileUnit); AssemblygeneratedAssembly=results.CompiledAssembly; //findthetypederivedfromSoapHttpClientProtocol TypewsProxyType=generatedAssembly.GetType(wsProxyTypeName); if(wsProxyType==null){ thrownewInvalidOperationException("Webserviceproxytypenotgenerated."); } //createaninstanceofthewebproxytype returnActivator.CreateInstance(wsProxyType); }
原文链接:http://www.jxszl.com/biancheng/C/556797.html