在wpf窗口中出现但也会出现异常

时间:2016-11-05 04:48:35

标签: wpf vb.net

我正在为wpf程序尝试一种新方法。我只写一个文件,即Application.xaml(代码给定)。 我还编写Driver3.vbproj来编译这个项目。不知怎的,我成功地获得了窗口部分 经过多次尝试 - 但接下来是一个例外。我使用命令行进行编译(C-Pad样式)。 通过VS2015社区版可以看到例外情况。 下面给出了详细的代码集: -

Application.xaml :-(下面给出的例外情况)

from test_rest_create_method.serializers import TempleSerializer
>>> serializer_temple = TempleSerializer()
>>> print(repr(serializer_temple))
TempleSerializer():
    history = CharField(style={'base_template': 'textarea.html'})
    timings = TimingsCreateUpdateSerializer(many=True):
        id = IntegerField(label='ID', read_only=True)
        Timings_to = TimeField(format='%I:%M%p')
        Timings_from = TimeField(format='%I:%M%p')
  

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

Driver3.vbproj

<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>

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

<?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>

有人可以帮助我压制或删除该异常吗?

1 个答案:

答案 0 :(得分: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