创造的VisualStudio的IronPython的项目时的错误; "异常被抛出调用的目标&QUOT。 [英] Error when creating an IronPython project in VisualStudio; "Exception has been thrown by the target of an invocation."

查看:1357
本文介绍了创造的VisualStudio的IronPython的项目时的错误; "异常被抛出调用的目标&QUOT。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这将对C#内置的GUI一个解决方案,我想创建在解决方案中IronPython的项目,该项目将被从C#code叫,但我甚至无法创建它。

我使用的是Python的工具从codePLEX和IronPython 2.7

编辑:这是我发现的ActivityLog.xml

  

System.Reflection.TargetInvocationException:异常被抛出调用的目标。 ---> System.Reflection.TargetInvocationException:无法加载语言IronPython的2.7.2.1:未找到方法:!! 1 [] Microsoft.Scripting.Utils.ArrayUtils.ConvertAll(!! 0],System.Func 2'; !! 0!1&GT;)。 ---&GT; System.MissingMethodException:未找到方法:!! 1 [] Microsoft.Scripting.Utils.ArrayUtils.ConvertAll(!! 0],System.Func 2)。在IronPython.Runtime.PythonContext..ctor(ScriptDomainManager经理的IDictionary 2个选项)---内部异常堆栈跟踪的结尾---在Microsoft.Scripting.Runtime.LanguageConfiguration.LoadLanguageContext(ScriptDomainManager domainManager,布尔和放大器; alreadyLoaded)在Microsoft.Scripting.Runtime.DlrConfiguration.LoadLanguageContext(ScriptDomainManager经理,LanguageConfiguration配置)在Microsoft.Scripting.Runtime.DlrConfiguration.TryLoadLanguage(ScriptDomainManager经理,AssemblyQualifiedTypeName的providerName,LanguageContext和放大器;语言)在Microsoft.Scripting.Runtime.ScriptDomainManager。 GetLanguageByTypeName(字符串providerAssemblyQualifiedTypeName)在Microsoft.Scripting.Hosting.ScriptRuntime.GetEngineByTypeName(字符串assemblyQualifiedTypeName)在IronPython.Hosting.Python.GetEngine(ScriptRuntime运行时)在Microsoft.IronPythonTools.Inter preter.RemoteInter preter..ctor ()在Microsoft.IronPythonTools.Inter preter.RemoteInter preterProxy..ctor()---内部异常堆栈跟踪的结尾---在System.RuntimeTypeHandle.CreateInstance(RuntimeType型,布尔publicOnly,布尔NOCHECK ,布尔和放大器; canBeCached,RuntimeMethodHandleInternal和放大器;构造函数,布尔和放大器; bNeedSecurityCheck)在System.RuntimeType.CreateInstanceSlow(布尔publicOnly,布尔skipCheckThis,布尔fillCache,StackCrawlMark和放大器; stackMark)在System.RuntimeType.CreateInstanceDefaultCtor(布尔publicOnly,布尔skipCheckThis,布尔fillCache,StackCrawlMark和放大器; stackMark)在System.Activator.CreateInstance(类型型,布尔非公开)在System.RuntimeType.CreateInstanceImpl(的BindingFlags bindingAttr,活页夹粘结剂,对象[]的args,CultureInfo的文化,对象[] activati​​onAttributes,StackCrawlMark和放大器; stackMark)在System.Activator.CreateInstance(类型类型,的BindingFlags bindingAttr,粘结剂粘结,对象[]的args,CultureInfo的文化,对象[] activati​​onAttributes)在System.Activator.CreateInstance(字符串assemblyString,字符串typeName的,布尔IGNORECASE,的BindingFlags bindingAttr,粘合剂粘合,对象[]的args,CultureInfo的文化,对象[] activati​​onAttributes,证据securityInfo,StackCrawlMark和放大器; stackMark)在System.Activator.CreateInstance(字符串的AssemblyName,字符串的typeName)在System.AppDomain.CreateInstance(字符串的AssemblyName,字符串的typeName)在System.AppDomain.CreateInstanceAndUnwrap(字符串的AssemblyName,字符串的typeName)在System.AppDomain。 CreateInstanceAndUnwrap(字符串的AssemblyName,字符串的typeName)在Microsoft.IronPythonTools.Inter$p$pter.IronPythonInter$p$pter.CreateDomain(RemoteInter$p$pterProxy& remoteInter preTER)在Microsoft.IronPythonTools.Inter preter.IronPythonInter preter.InitializeRemoteDomain()在Microsoft.IronPythonTools.Inter preter.IronPythonInter preter..ctor(IronPythonInter preterFactory工厂,PythonTypeDatabase typeDb)在Microsoft.IronPythonTools.Inter preter.IronPythonInter preterFactory.CreateInter preTER()在Microsoft.P​​ythonTools.Repl.PythonReplEvaluator.get_ReplAnalyzer()在Microsoft.P​​ythonTools.Extensions.GetAnalyzer (ITextView的TextView)在Microsoft.PythonTools.Intellisense.IntellisenseControllerProvider.TryCreateIntellisenseController(ITextView TextView的,IList的 1 subjectBuffers)在Microsoft.VisualStudio.Language.Intellisense.Implementation.IntellisenseManagerConnectionListener.<>c_DisplayClass5.b_1(IIntellisenseControllerProvider提供商)在Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InstantiateExtension[TExtension,TMetadata,TExtensionInstance](Object errorSource,懒 2提供商,Func键 2的getter)

生成的code是如下(这个项目仍然没有在解决方案中显示)

project1.py:

 打印(世界你好)
 

改变了上面打印的Hello world,因为我正在使用Python 2.7,但它并没有解决问题。

project1.pyproj:

 &LT; XML版本=1.0编码=UTF-8&GT?;
&LT;项目DefaultTargets =生成的xmlns =htt​​p://schemas.microsoft.com/developer/msbuild/2003&GT;
  &LT;的PropertyGroup&GT;
    &lt;结构状态='$(配置)'==''&GT;调试和LT; /结构&gt;
    &LT; SchemaVersion&GT; 2.0&LT; / SchemaVersion&GT;
    &LT; ProjectGuid&GT; 690e6ad3-edb2-42cc-8db1-85cdf487d241&LT; / ProjectGuid&GT;
    &LT; PROJECTHOME&GT;&LT; / PROJECTHOME&GT;
    &LT; StartupFile&GT; WebScraper.py&LT; / StartupFile&GT;
    &LT; SearchPath中的&GT;
    &LT; / SearchPath中的&GT;
    &LT; WorkingDirectory&GT;&LT; / WorkingDirectory&GT;
    &LT;国米preterId&GT; 80659ab7-4d53-4e0c-8588-a766116cbd46&LT; /间preterId&GT;
    &LT; LaunchProvider&GT; IronPython的(.NET)发射器和LT; / LaunchProvider&GT;
    &LT;国米preterVersion&GT; 2.7&LT; /间preterVersion&GT;
    &LT; OutputPath&GT;&LT; / OutputPath&GT;
    &LT;名称&gt;&WebScraper LT; /名称&gt;
    &LT; RootNamespace&GT; WebScraper&LT; / RootNamespace&GT;
  &LT; /的PropertyGroup&GT;
  &LT;的PropertyGroup条件='$(配置)'=='调试'&GT;
    &LT; D​​ebugSymbols&GT;真&LT; / DebugSymbols&GT;
    &LT; EnableUnmanagedDebugging&GT;假&LT; / EnableUnmanagedDebugging&GT;
  &LT; /的PropertyGroup&GT;
  &LT;的PropertyGroup条件='$(配置)'=='释放'&GT;
    &LT; D​​ebugSymbols&GT;真&LT; / DebugSymbols&GT;
    &LT; EnableUnmanagedDebugging&GT;假&LT; / EnableUnmanagedDebugging&GT;
  &LT; /的PropertyGroup&GT;
  &LT; ItemGroup&GT;
    &LT;无包括=WebScraper.py/&GT;
  &LT; / ItemGroup&GT;
  &LT;导入项目=$(MSBuildToolsPath)\ Microsoft.Common.targets/&GT;
&LT; /项目&GT;
 

解决方案

在最后的解决方案来到了卸载所有的IronPython的(2.6和2.7),然后卸载Python的工具Visual Studio中。然后重新安装的IronPython 2.7,并选择组件时(我认为这是一个重要的组成部分,因为他们彼此按照我的理解发生冲突),然后重新安装Python的工具1.5版(我用VS 2012)

I have a solution which will have a GUI built in on C# and I want to create a IronPython project in the solution which will be called from the C# code but I can't even create it.

I'm using the python tools from CodePlex and IronPython 2.7

Edit: This is I found in the ActivityLog.xml

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Failed to load language 'IronPython 2.7.2.1': Method not found: '!!1[] Microsoft.Scripting.Utils.ArrayUtils.ConvertAll(!!0[], System.Func2<!!0,!!1>)'. ---> System.MissingMethodException: Method not found: '!!1[] Microsoft.Scripting.Utils.ArrayUtils.ConvertAll(!!0[], System.Func2)'. at IronPython.Runtime.PythonContext..ctor(ScriptDomainManager manager, IDictionary2 options) --- End of inner exception stack trace --- at Microsoft.Scripting.Runtime.LanguageConfiguration.LoadLanguageContext(ScriptDomainManager domainManager, Boolean& alreadyLoaded) at Microsoft.Scripting.Runtime.DlrConfiguration.LoadLanguageContext(ScriptDomainManager manager, LanguageConfiguration config) at Microsoft.Scripting.Runtime.DlrConfiguration.TryLoadLanguage(ScriptDomainManager manager, AssemblyQualifiedTypeName providerName, LanguageContext& language) at Microsoft.Scripting.Runtime.ScriptDomainManager.GetLanguageByTypeName(String providerAssemblyQualifiedTypeName) at Microsoft.Scripting.Hosting.ScriptRuntime.GetEngineByTypeName(String assemblyQualifiedTypeName) at IronPython.Hosting.Python.GetEngine(ScriptRuntime runtime) at Microsoft.IronPythonTools.Interpreter.RemoteInterpreter..ctor() at Microsoft.IronPythonTools.Interpreter.RemoteInterpreterProxy..ctor() --- End of inner exception stack trace --- at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at System.Activator.CreateInstance(String assemblyString, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark) at System.Activator.CreateInstance(String assemblyName, String typeName) at System.AppDomain.CreateInstance(String assemblyName, String typeName) at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName) at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName) at Microsoft.IronPythonTools.Interpreter.IronPythonInterpreter.CreateDomain(RemoteInterpreterProxy& remoteInterpreter) at Microsoft.IronPythonTools.Interpreter.IronPythonInterpreter.InitializeRemoteDomain() at Microsoft.IronPythonTools.Interpreter.IronPythonInterpreter..ctor(IronPythonInterpreterFactory factory, PythonTypeDatabase typeDb) at Microsoft.IronPythonTools.Interpreter.IronPythonInterpreterFactory.CreateInterpreter() at Microsoft.PythonTools.Repl.PythonReplEvaluator.get_ReplAnalyzer() at Microsoft.PythonTools.Extensions.GetAnalyzer(ITextView textView) at Microsoft.PythonTools.Intellisense.IntellisenseControllerProvider.TryCreateIntellisenseController(ITextView textView, IList1 subjectBuffers) at Microsoft.VisualStudio.Language.Intellisense.Implementation.IntellisenseManagerConnectionListener.<>c_DisplayClass5.b_1(IIntellisenseControllerProvider provider) at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InstantiateExtension[TExtension,TMetadata,TExtensionInstance](Object errorSource, Lazy2 provider, Func2 getter)

The generated code is as following (this project still is not displayed in the Solution)

project1.py :

print("hello world")

Changed the above to print "Hello world" since I'm using Python 2.7 but it didn't fix the problem

project1.pyproj:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>690e6ad3-edb2-42cc-8db1-85cdf487d241</ProjectGuid>
    <ProjectHome>.</ProjectHome>
    <StartupFile>WebScraper.py</StartupFile>
    <SearchPath>
    </SearchPath>
    <WorkingDirectory>.</WorkingDirectory>
    <InterpreterId>80659ab7-4d53-4e0c-8588-a766116cbd46</InterpreterId>
    <LaunchProvider>IronPython (.NET) launcher</LaunchProvider>
    <InterpreterVersion>2.7</InterpreterVersion>
    <OutputPath>.</OutputPath>
    <Name>WebScraper</Name>
    <RootNamespace>WebScraper</RootNamespace>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
    <DebugSymbols>true</DebugSymbols>
    <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
    <DebugSymbols>true</DebugSymbols>
    <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
  </PropertyGroup>
  <ItemGroup>
    <None Include="WebScraper.py" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
</Project>

解决方案

The solution at the end came down to uninstalling all IronPython's (2.6 and 2.7) and then uninstalling the Python Tools for Visual Studio. Then reinstalling IronPython 2.7 and not installing any of the "Tools" when selecting components (I think this is an important part since they clash with each other as I understand it) Then reinstalling the Python Tools version 1.5 (I use VS 2012)

这篇关于创造的VisualStudio的IronPython的项目时的错误; &QUOT;异常被抛出调用的目标&QUOT。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆