我有一個解決方案,它將在C#中構建一個GUI,並且我想在C#代碼中調用的解決方案中創建一個IronPython項目,但我甚至無法創建它。在VisualStudio中創建IronPython項目時出錯; 「調用目標引發了異常。」
我使用CodePlex從和IronPython Python的工具2.7
編輯:這是我在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.Func
2<!!0,!!1>)'. ---> System.MissingMethodException: Method not found: '!!1[] Microsoft.Scripting.Utils.ArrayUtils.ConvertAll(!!0[], System.Func
2)」中。在Microsoft.VisualStudio.Language.Intellisense.Implementation.IntellisenseManagerConnectionListener的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, IList
1 subjectBuffers)。 <> C_ DisplayClass5.b _1在Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InstantiateExtension [範圍延伸,TMetadata,TExtensionInstance](IIntellisenseControllerProvider提供商)(對象errorSource,懶惰2 provider, Func
2吸氣劑)
所生成的代碼如下(這個項目仍然沒有在解決方案中顯示)
project1.py:
print("hello world")
改變上述以print "Hello world"
因爲我使用Python 2.7,但它並沒有解決問題
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>
什麼是你的異常的「InnerException」? –
這就是我看到的所有信息,它會彈出一個提醒對話框。我不知道如何從中獲取更多信息 –
當您收到對話框時,您需要查看異常的詳細信息。然後,您可以檢查InnerException以查看「真實」異常是什麼。確保你在Debug下運行,而不是Release。 –