user1744515
user1744515

Reputation: 1

In wpf window appears but exception also appears

I am trying a new method for wpf program. I write only one file i.e. Application.xaml (Code given). I also write Driver3.vbproj to compile this project. Somehow I succeeded in getting the window part after repeated attempts - but an exception follows. I use command line for compiling (C-Pad style). The exception can be seen through VS2015 community edition. Detailed codesets given below:-

Application.xaml:-(Exception details given below)

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

An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: 'The invocation of the constructor on type 'System.Windows.Application' that matches the specified binding constraints threw an exception.'
Line number '1' and line position '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>

Commandline call for compiler:-(The project is on my desktop)

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

Can somebody help me out to suppress or remove that exception?

Upvotes: 1

Views: 98

Answers (1)

user1744515
user1744515

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

Upvotes: 1

Related Questions