c# InnerException of socket in XamlParseException -
i have been developing basic c# chat application practice networking in c# , have built stable build application came across strange thing when started second instance of application in visual studio debugger. while first instance running flawlessly second instance gave xamlparseexception
in initializecomponents()
function. had inner exception of only 1 usage of each socket address (protocol/network address/port) permitted.
what confuses me working , creating , managing of sockets being done in subsequent lines of code on end, how simple parsing of xaml giving rise exception (which parsed flawlessly in case of first instance of application running).
even if program needs have exception thrown due conflicting sockets, should thrown later(while binding tcp/ while sending udp) can debug transmission throwing exception, in case fails @ first line
initializecomponents()
only.
thanks lot in advance , please edit title/content more appropriate if needed. if code needed please comment , provide it.
edit- googling gave no possible relation between 2 xamlparseexception
, 1 usage of socket exception. xamlparseexception
linked errors in xaml apparent while in case of socket exception due conflicting sockets on same port.
here's xaml-code:
<window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:chatapp" xmlns:conv="clr-namespace:converters" xmlns:commands="clr-namespace:custom_commands" xmlns:system="clr-namespace:system;assembly=mscorlib" x:name="wnd" x:class="chatapp.mainwindow" mc:ignorable="d" title="mainwindow" height="600" width="700" minwidth="550" minheight="450" contentrendered="sort"> <window.resources> <conv:sub x:key="converter_sub" /> <conv:margin_sub x:key="converter_margin_sub" /> <conv:button_margin_sub x:key="converter_button_margin_sub" /> <conv:mul x:key="converter_mul" /> <conv:mul_and_sub x:key="converter_mul_and_sub" /> <conv:sub_and_mul x:key="converter_sub_and_mul" /> <conv:tab_width_calc x:key="tab_calc" /> <conv:messagebox_width_calc x:key="messagebox_calc" /> <conv:join_nick_and_ip x:key="join_nick_and_ip" /> <conv:subtract_two_multibindings x:key="subtract_two_multibindings" /> <conv:status_bar_text x:key="status_bar_text" /> <storyboard x:key="show_log" > <thicknessanimation storyboard.targetproperty="margin" to="0,0,0,0" decelerationratio=".9" duration="0:0:0.8"/> </storyboard> <storyboard x:key="hide_log" > <thicknessanimation storyboard.targetproperty="margin" to="0,0,-210,0" decelerationratio=".9" duration="0:0:0.8"/> </storyboard> <storyboard x:key="show_rect" > <doubleanimation storyboard.targetproperty="opacity" to="0.1" duration="0:0:0.5"/> </storyboard> <storyboard x:key="hide_rect" > <doubleanimation storyboard.targetproperty="opacity" to="0" duration="0:0:0.5" /> </storyboard> </window.resources> <window.commandbindings> <commandbinding command="commands:custom_commands.exit" executed="exitcommand_executed"/> <commandbinding command="commands:custom_commands.connect_new" executed="manuallyconnectcommand_executed"/> </window.commandbindings> <grid> <grid.columndefinitions> <columndefinition/> </grid.columndefinitions> <grid.rowdefinitions> <rowdefinition height="25"/> <rowdefinition/> <rowdefinition height="20"/> </grid.rowdefinitions> <rectangle fill="gray" opacity="0" panel.zindex="-1" name="hide_log_rect" horizontalalignment="left" height="{binding actualheight, converterparameter=25, converter={staticresource converter_sub}, elementname=wnd}" stroke="transparent" verticalalignment="top" width="{binding actualwidth, elementname=wnd}" grid.rowspan="2" mouse.mouseup="hide_log"/> <rectangle fill="transparent" opacity="0" panel.zindex="-1" name="lose_searcharea_focus_rect" horizontalalignment="right" height="{binding actualheight, converterparameter=25, converter={staticresource converter_sub}, elementname=wnd}" stroke="transparent" verticalalignment="top" grid.rowspan="2" mouse.mouseup="lose_searcharea_focus_rect_mouseup"> <rectangle.width> <multibinding converter="{staticresource subtract_two_multibindings}" converterparameter="10"> <binding path="actualwidth" elementname="wnd"/> <binding path="actualwidth" elementname="status_area"/> </multibinding> </rectangle.width> </rectangle> <menu ismainmenu="true" panel.zindex="1" x:name="menu" horizontalalignment="left" height="25" verticalalignment="top" width= "{binding actualwidth, elementname=wnd}"> <menuitem header="file"> <menuitem header="exit" command="commands:custom_commands.exit" /> </menuitem> <menuitem header="options"> <menuitem header="connect manually" command="commands:custom_commands.connect_new"/> <menuitem x:name="toggle_server" header="server running" click="toggle_server_status" ischeckable="true" ischecked="true"/> <menuitem x:name="toggle_broadcast" header="server broadcasting" click="toggle_broadcasting" ischeckable="true" ischecked="true"/> </menuitem> </menu> <statusbar panel.zindex="51" height="20" grid.row="2" verticalalignment="top" width="{binding actualwidth, elementname=wnd}"> <statusbaritem margin="{binding elementname=wnd, path=actualwidth, converter={staticresource converter_margin_sub}, converterparameter=260}"> <textblock fontsize="11.5" text="{binding elementname=toggle_server, path=ischecked, converter={staticresource status_bar_text}, converterparameter=0}"/> </statusbaritem> <separator/> <statusbaritem> <textblock fontsize="11.5" text="{binding elementname=toggle_broadcast, path=ischecked, converter={staticresource status_bar_text},converterparameter= 1}"/> </statusbaritem> </statusbar> <grid panel.zindex="3" x:name="grid1" horizontalalignment="left" height="{binding actualheight, converterparameter=25, converter={staticresource converter_sub}, elementname=wnd}" grid.row="1" verticalalignment="top" width="{binding actualwidth, elementname=wnd}"> <grid.columndefinitions> <columndefinition width="100*" maxwidth="228.61272" minwidth="140.63584"/> <columndefinition width="250*"/> </grid.columndefinitions> <canvas grid.column="0" grid.row="0" name="status_area" focusmanager.gotfocus="search_area_gotfocus"> <listview x:name="listview" height="{binding actualheight, converterparameter=103, converter={staticresource converter_sub}, elementname=grid1}" canvas.left="10" canvas.top="43" maxwidth="210" width="{binding actualwidth, converterparameter=0.2857143-20, converter={staticresource converter_mul_and_sub}, elementname=grid1}"> <listview.resources> <contextmenu x:key="context_menu"> <menuitem header="connect" click="broadcast_list_connect"> <menuitem.tag> <multibinding converter="{staticresource join_nick_and_ip}"> <binding path="nick"/> <binding path="ip"/> </multibinding> </menuitem.tag> </menuitem> </contextmenu> </listview.resources> <listview.itemcontainerstyle> <style targettype="listboxitem"> <setter property="contextmenu" value="{staticresource context_menu}"> </setter> </style> </listview.itemcontainerstyle> <listview.view> <gridview> <gridviewcolumn width="{binding actualwidth, converterparameter=10, converter={staticresource converter_sub}, elementname=listview}" displaymemberbinding="{binding nick}"> <gridviewcolumnheader x:name="sort_header" tag="name" click="sort" > <textblock horizontalalignment="center"><run text="nick "/></textblock> </gridviewcolumnheader> </gridviewcolumn> </gridview> </listview.view> </listview> <textbox x:name="search_textbox" height="28" canvas.left="10" textwrapping="wrap" text="search.." canvas.top="5" width="{binding actualwidth, converterparameter=0.2857143-20, converter={staticresource converter_mul_and_sub}, elementname=grid1}" maxwidth="210" keyup="search_textbox_keyup"/> </canvas> <canvas grid.column="1" grid.row="0"> <tabcontrol selectionchanged="tab_selectionchanged" x:name="tabcontrol" height="{binding actualheight, converterparameter=65, converter={staticresource converter_sub}, elementname=grid1}" width="{binding actualwidth, converterparameter=0.7142857-228.61272, converter={staticresource tab_calc}, elementname=grid1}" canvas.top="5"/> </canvas> </grid> <canvas panel.zindex="51" x:name="log_canvas" background="cornflowerblue" horizontalalignment="right" height="{binding actualheight, converterparameter=35, converter={staticresource converter_sub}, elementname=grid1}" margin="0,0,-210,0" verticalalignment="top" width="210" grid.rowspan="2" opacity="0.9"> <menu height="25"> <menuitem width="31" height="25" horizontalalignment="right" margin="-210,0,0,0" x:name="log_menu_button" click="toggle_log" > <menuitem.effect> <dropshadoweffect blurradius="2" shadowdepth="2"/> </menuitem.effect> <menuitem.icon> <image width="20" height="20" source="resources/menu.png" margin="3,0,0,2"/> </menuitem.icon> </menuitem> </menu> <listbox x:name="log" background="white" height="{binding actualheight, converterparameter=25, converter={staticresource converter_sub}, elementname=log_canvas}" canvas.top="25" width="210"/> </canvas> </grid>
and small suppose relevant part of c# main class constructor code:
public mainwindow() { initializecomponent(); get_machine_name(); server_start(); receive_broadcasts(); thread thread = new thread(() => update_available_clients()); thread.name = "bradcast list update"; thread.isbackground = true; thread.start(); . . . . }
here exception thrown in line 1 initializecomponents() only, not proceeding subsequent lines actual functions server_start() interact sockets called.
the call stack:
presentationframework.dll!system.windows.markup.wpfxamlloader.load(system.xaml.xamlreader xamlreader, system.xaml.ixamlobjectwriterfactory writerfactory, bool skipjournaledproperties, object rootobject, system.xaml.xamlobjectwritersettings settings, system.uri baseuri) unknown presentationframework.dll!system.windows.markup.wpfxamlloader.loadbaml(system.xaml.xamlreader xamlreader, bool skipjournaledproperties, object rootobject, system.xaml.permissions.xamlaccesslevel accesslevel, system.uri baseuri) unknown presentationframework.dll!system.windows.markup.xamlreader.loadbaml(system.io.stream stream, system.windows.markup.parsercontext parsercontext, object parent, bool closestream) unknown presentationframework.dll!system.windows.application.loadbamlstreamwithsyncinfo(system.io.stream stream, system.windows.markup.parsercontext pc) unknown presentationframework.dll!system.windows.application.loadcomponent(system.uri resourcelocator, bool bskipjournaledproperties) unknown presentationframework.dll!system.windows.application.dostartup() unknown presentationframework.dll!system.windows.application._ctor.anonymousmethod__0(object unused) unknown windowsbase.dll!system.windows.threading.exceptionwrapper.internalrealcall(system.delegate callback, object args, int numargs) unknown windowsbase.dll!system.windows.threading.exceptionwrapper.trycatchwhen(object source, system.delegate callback, object args, int numargs, system.delegate catchhandler) unknown windowsbase.dll!system.windows.threading.dispatcheroperation.invokeimpl() unknown windowsbase.dll!system.windows.threading.dispatcheroperation.invokeinsecuritycontext(object state) unknown mscorlib.dll!system.threading.executioncontext.runinternal(system.threading.executioncontext executioncontext, system.threading.contextcallback callback, object state, bool preservesyncctx) unknown mscorlib.dll!system.threading.executioncontext.run(system.threading.executioncontext executioncontext, system.threading.contextcallback callback, object state, bool preservesyncctx) unknown mscorlib.dll!system.threading.executioncontext.run(system.threading.executioncontext executioncontext, system.threading.contextcallback callback, object state) unknown windowsbase.dll!system.windows.threading.dispatcheroperation.invoke() unknown windowsbase.dll!system.windows.threading.dispatcher.processqueue() unknown windowsbase.dll!system.windows.threading.dispatcher.wndprochook(system.intptr hwnd, int msg, system.intptr wparam, system.intptr lparam, ref bool handled) unknown windowsbase.dll!ms.win32.hwndwrapper.wndproc(system.intptr hwnd, int msg, system.intptr wparam, system.intptr lparam, ref bool handled) unknown windowsbase.dll!ms.win32.hwndsubclass.dispatchercallbackoperation(object o) unknown windowsbase.dll!system.windows.threading.exceptionwrapper.internalrealcall(system.delegate callback, object args, int numargs) unknown windowsbase.dll!system.windows.threading.exceptionwrapper.trycatchwhen(object source, system.delegate callback, object args, int numargs, system.delegate catchhandler) unknown windowsbase.dll!system.windows.threading.dispatcher.legacyinvokeimpl(system.windows.threading.dispatcherpriority priority, system.timespan timeout, system.delegate method, object args, int numargs) unknown windowsbase.dll!ms.win32.hwndsubclass.subclasswndproc(system.intptr hwnd, int msg, system.intptr wparam, system.intptr lparam) unknown [native managed transition] [managed native transition] windowsbase.dll!system.windows.threading.dispatcher.pushframeimpl(system.windows.threading.dispatcherframe frame) unknown windowsbase.dll!system.windows.threading.dispatcher.pushframe(system.windows.threading.dispatcherframe frame) unknown presentationframework.dll!system.windows.application.rundispatcher(object ignore) unknown presentationframework.dll!system.windows.application.runinternal(system.windows.window window) unknown presentationframework.dll!system.windows.application.run(system.windows.window window) unknown chatapp.exe!chatapp.app.main() c# [native managed transition] [managed native transition] mscorlib.dll!system.appdomain.executeassembly(string assemblyfile, system.security.policy.evidence assemblysecurity, string[] args) unknown microsoft.visualstudio.hostingprocess.utilities.dll!microsoft.visualstudio.hostingprocess.hostproc.runusersassembly() unknown mscorlib.dll!system.threading.threadhelper.threadstart_context(object state) unknown mscorlib.dll!system.threading.executioncontext.runinternal(system.threading.executioncontext executioncontext, system.threading.contextcallback callback, object state, bool preservesyncctx) unknown mscorlib.dll!system.threading.executioncontext.run(system.threading.executioncontext executioncontext, system.threading.contextcallback callback, object state, bool preservesyncctx) unknown mscorlib.dll!system.threading.executioncontext.run(system.threading.executioncontext executioncontext, system.threading.contextcallback callback, object state) unknown mscorlib.dll!system.threading.threadhelper.threadstart() unknown
and stacktrace outer xamlparseexception string:
" @ system.windows.markup.wpfxamlloader.load(xamlreader xamlreader, ixamlobjectwriterfactory writerfactory, boolean skipjournaledproperties, object rootobject, xamlobjectwritersettings settings, uri baseuri)"
for socket inner exception stacktrace string was:
" @ system.net.sockets.socket.dobind(endpoint endpointsnapshot, socketaddress socketaddress)\r\n @ system.net.sockets.socket.bind(endpoint localep)\r\n @ system.net.sockets.udpclient..ctor(int32 port, addressfamily family)\r\n @ chatapp.mainwindow..ctor() in c:\users\kaustubh\documents\visual studio 2015\projects\chatapplication\chatapp\mainwindow.xaml.cs:line 100"
thanks , if need more code, please tell.
i had data member initialised as
private udpclient broadcast_receiver= new udpclient(15069);
and failing bind port , hence error since members being initialised along initilisecomponents() call exception being thrown.
Comments
Post a Comment