2016-11-05 43 views
1

我正在尝试wpf程序的新方法。我只写了一个文件,即Application.xaml(给出的代码)。 我也编写Driver3.vbproj来编译这个项目。不知何故,我成功地在重复尝试后获得了窗口部分 - 但有一个例外如下。我使用命令行进行编译(C-Pad风格)。 通过VS2015社区版可以看出这个例外。下面给出详细 代码集: - 下面给出在wpf窗口出现,但也出现异常

Application.xaml :-(异常详细信息)

<Application x:Class="Application" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    StartupUri="C:\Users\VEKATRAMAN\Desktop\Dll_Output_Testing_Proj\Application.xaml"> 
<x:Code> 

     <![CDATA[ 

Public Sub New1() 
      InitializeComponent() 
Try  

Dim won As Object = New Window() 
       won.Height="300" 
       won.Width="900" 
       won.Title="Guddlu_3" 
       won.Background=New SolidColorBrush(Colors.LightSteelBlue) 
won.Show() 
Catch ex As Exception 
     MsgBox("Something wrong somewhere!!??!!") 
End Try 

End Sub 

     ]]> 
</x:Code> 

</Application> 

类型的未处理的异常 'System.Windows.Markup.XamlParseException' 发生PresentationFramework。 dll
附加信息:'类型 'System.Windows.Application'上构造函数的调用匹配 指定的绑定约束抛出异常。
行号“1”和行位置“14”。

Driver3.vbproj

<?xml version="1.0" encoding="utf-8"?> 
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 
    <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> 
    <PropertyGroup> 
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> 
    <ProjectGuid>{BE9B3350-5541-4EB5-BD4D-F6938B472E5E}</ProjectGuid> 
    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids> 
    <OutputType>WinExe</OutputType> 
    <RootNamespace>Driver3</RootNamespace> 
    <AssemblyName>Driver3</AssemblyName> 
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> 
    <MyType>Custom</MyType> 
    </PropertyGroup> 
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> 
    <PlatformTarget>AnyCPU</PlatformTarget> 
    <DebugSymbols>true</DebugSymbols> 
    <DebugType>full</DebugType> 
    <DefineDebug>true</DefineDebug> 
    <DefineTrace>true</DefineTrace> 
    <IncrementalBuild>true</IncrementalBuild> 
    <OutputPath>bin\Debug\</OutputPath> 
    <DocumentationFile>Driver3.xml</DocumentationFile> 
    <NoWarn>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314</NoWarn> 
    </PropertyGroup> 
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> 
    <PlatformTarget>AnyCPU</PlatformTarget> 
    <DebugType>pdbonly</DebugType> 
    <DebugSymbols>false</DebugSymbols> 
    <DefineDebug>false</DefineDebug> 
    <DefineTrace>true</DefineTrace> 
    <IncrementalBuild>false</IncrementalBuild> 
    <Optimize>true</Optimize> 
    <OutputPath>bin\Release\</OutputPath> 
    <DocumentationFile>Driver3.xml</DocumentationFile> 
    <NoWarn>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314</NoWarn> 
    </PropertyGroup> 
    <PropertyGroup> 
    <OptionExplicit>On</OptionExplicit> 
    </PropertyGroup> 
    <PropertyGroup> 
    <OptionCompare>Binary</OptionCompare> 
    </PropertyGroup> 
    <PropertyGroup> 
    <OptionStrict>Off</OptionStrict> 
    </PropertyGroup> 
    <PropertyGroup> 
    <OptionInfer>On</OptionInfer> 
    </PropertyGroup> 
    <ItemGroup>  
    <Reference Include="System.Core" /> 
    <Reference Include="system.windows.controls.ribbon" /> 
    <Reference Include="System.Xml.Linq" /> 
    <Reference Include="System.Data.DataSetExtensions" /> 
    <Reference Include="System" /> 
    <Reference Include="System.Data" /> 
    <Reference Include="System.Xml" />  
    <Reference Include="System.Xaml"> 
     <RequiredTargetFramework>4.0</RequiredTargetFramework> 
    </Reference> 
    <Reference Include="UIAutomationProvider" /> 
    <Reference Include="UIAutomationTypes" /> 
    <Reference Include="WindowsBase" /> 
    <Reference Include="PresentationCore" /> 
    <Reference Include="PresentationFramework" />   
    </ItemGroup> 
    <ItemGroup> 
    <ApplicationDefinition Include="C:\Users\VEKATRAMAN\Desktop\Dll_Output_Testing_Proj\Application.xaml"> 
     <Generator>MSBuild:Compile</Generator> 
     <SubType>Designer</SubType> 
    </ApplicationDefinition>   
    </ItemGroup> 
    <ItemGroup>  
    <Import Include="System.Windows.Shapes"/> 
    <Import Include="System.Attribute"/> 
    <Import Include="System.Collections.Generic"/> 
    <Import Include="System.Collections"/> 
    <Import Include="System.ComponentModel"/> 
    <Import Include="System.Data"/> 
    <Import Include="System.Diagnostics"/> 
    <Import Include="System.Drawing"/> 
    <Import Include="System.Linq"/> 
    <Import Include="Microsoft.VisualBasic"/> 
    <Import Include="System.Net"/> 
    <Import Include="System.Net.WebClient"/> 
    <Import Include="System.Object"/> 
    <Import Include="System.Reflection" /> 
    <Import Include="System.Runtime.InteropServices"/> 
    <Import Include="System.IO"/> 
    <Import Include="System"/> 
    <Import Include="System.Web"/> 
    <Import Include="System.Windows"/> 
    <Import Include="System.Windows.Automation.Peers"/> 
    <Import Include="System.Windows.Controls"/> 
    <Import Include="System.Windows.Data"/> 
    <Import Include="System.Windows.Documents"/> 
    <Import Include="System.Windows.Input"/> 
    <Import Include="System.Windows.Media"/> 
    <Import Include="System.Windows.Media.Imaging"/> 
    <Import Include="System.Windows.Navigation"/> 
    <Import Include="System.Windows.Shapes"/> 
    <Import Include="System.Windows.Threading"/> 
    <Import Include="System.Windows.Threading.DispatcherTimer"/> 
    <Import Include="System.Text"/> 
    <Import Include="System.Threading"/> 
    <Import Include="System.Threading.Tasks"/> 
    <Import Include="System.Xml"/> 
    <Import Include="System.Xml.Linq"/>  
    </ItemGroup> 
    <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" /> 
</Project> 

命令行调用编译器:-(该项目是我的桌面上)

set PATH=%PATH%;C:\Program Files (x86)\MSBuild\14.0\Bin 
msbuild "C:\Friends 

有人可以帮我去抑制或删除例外?

+0

请格式化您的问题。我无法理解你的问题。 – MSL

回答

1
Dear Friends, 
    I am very happily announcing that I solved my own problem.The solution was very simple indeed. 
SOLUTION: 
Remove the line--> StartupUri="Application.xaml" 
The window appears and is stable.Just for clarity I am repeating the Application.xaml file code:- 

<Application x:Class="Application" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 

<x:Code> 
     <![CDATA[ 

Public Sub New() 
Dim won As Object = New Window() 
       won.Height="300" 
       won.Width="900" 
       won.Title="Guddlu_3" 
       won.Background=New SolidColorBrush(Colors.LightSteelBlue) 
won.Show()    
End Sub 

     ]]> 
</x:Code> 

</Application> 

Driver3.vbproj is the same 

Thanks a lot and regards to all. 
Venkatraman 
+0

这里同样的问题。 [这](https://stackoverflow.com/questions/1945843/how-to-change-startupuri-of-wpf-application)是相关的。 –