this is baffling me, I would appreciate some help. I have a thread that loads databases from a server in the background into a custom control that I've created.
The thread retrieves the databases just fine, but when I try to access some methods in my custom control i get thrown that exception and I don't know why!!
here's my code:
{
DatabaseLoader = new Thread(()=> AquireDatabases(LoginInfo));
DatabaseLoader.Name = "DatabaseLoader";
DatabaseLoader.IsBackground = true;
DatabaseLoader.Start();
}
private void AquireDatabases(List<Object> loginInfo)
{
DataTable dtDatabases = new DataTable();
try
{
dtDatabases = objBkp.FillCBDatabases(loginInfo[0].ToString(), loginInfo[1].ToString(), loginInfo[2].ToString());
}
catch (Exception ex)
{
string s = ex.ToString();
MessageBox.Show(s);
}
LoadDatabasesinControl(dtDatabases, null);
}
private void LoadDatabasesinControl(DataTable dtDatabases, RunWorkerCompletedEventArgs e)
{
if (InvokeRequired)
{
this.Invoke(new WorkerCompleteDelegate(LoadDatabasesinControl), dtDatabases, e);
return;
}
if (DatabaseLoader.IsAlive || !(DatabaseLoader.ThreadState == ThreadState.AbortRequested))
{
// CLEAR ALL ITEMS IN the control before filling it
serverControl.ClearControl(); // --> EXCEPTION THROWN
for (int i = 0; i < dtDatabases.Rows.Count; i++)
{
serverControl.CreateDatabase();
serverControl.DatabaseName = dtDatabases.Rows[i][0].ToString();
serverControl.lblSubDBSize = 150513; // --> EXCEPTION THROWN
}
}
}
method ClearControl() is a public method in my control, and it returns type void just like CreateDatabase()
also, lblSubDBSize is a regular public label just like DatabaseName!
Why is the exception being thrown on these two only, and none of the other functions I try to access???
I think this is a thread problem but I don't know what it is exactly.
I added my custom control as an existing project and I added the reference to it as a project to my solution instead of as a dll. I read somewhere that that could be that cause but it wasn't, I tried a bunch of stuff with no luck.
Any thoughts anyone???
[EDIT]
serverControl is a custom User Control
public Database database;
private Label lblServer;
private Button btnServerPanelExpander;
private Panel pnlServerHeader;
private List<Database> databaseCollection = new List<Database>();
public ServerControl()
{
InitializeComponent();
ControlInitializer();
}
private void ControlInitializer()
{
lblServer = new Label();
pnlServerHeader = new Panel();
btnServerPanelExpander = new Button();
btnServerPanelExpander.Click += btnServerPanelExpander_Click;
pnlServerHeader.Controls.Add(btnServerPanelExpander);
pnlServerHeader.Controls.Add(lblServer);
pnlServer.Controls.Add(pnlServerHeader);
setProperties();
}
public void ClearControl()
{
if (database == null)
return;
this.pnlServer.Controls.Clear();
this.ControlInitializer();
this.pnlServer.Invalidate();
}
public void CreateDatabase()
{
database = new Database();
database.SetIcon(DatabaseIcon);
databaseCollection.Add(database);
pnlServer.Controls.Add(database.pnlDatabase);
DrawDatabase(database);
}
and here is the stack trace and exception... hope this clarifies things
Exception Message
"Method not found: 'Void ServersControl.ServerControl.ClearControl()'."
Stack Trace
" at Forms.MainSmall.LoadDatabasesinControl(DataTable dtDatabases, RunWorkerCompletedEventArgs e)\r\n at Forms.MainSmall.AquireDatabases(List`1 loginInfo)\r\n at Forms.MainSmall.b__1370_0()\r\n at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n at System.Threading.ThreadHelper.ThreadStart()"
Related
I have created simple form for editing client list using Entity Framework and data binding. However, when im trying to edit rows error "An entity object cannot be referenced by multiple instances of IEntityChangeTracker" occurs. I don't know where I attach one object to two data contexts..
Main user control:
ArtGalleryEntities db;
public UserControl5()
{
InitializeComponent();
}
private void UserControl5_Load(object sender, EventArgs e)
{
db = new ArtGalleryEntities();
db.Configuration.LazyLoadingEnabled = false;
klienciBindingSource.DataSource = db.Klienci.ToList();
}
private void edit_button_Click(object sender, EventArgs e)
{
if (klienciBindingSource.Current == null)
return;
using (AddEditForm frm = new AddEditForm(klienciBindingSource.Current as Klienci))
{
if (frm.ShowDialog() == DialogResult.OK)
{
klienciBindingSource.DataSource = db.Klienci.ToList();
}
}
}
AddEditForm here :
ArtGalleryEntities db;
public AddEditForm(Klienci obj)
{
InitializeComponent();
db = new ArtGalleryEntities();
if (obj == null)
{
klienciBindingSource.DataSource = new Klienci();
db.Klienci.Add(klienciBindingSource.Current as Klienci);
}
else
{
db.Entry(obj).State = System.Data.Entity.EntityState.Unchanged;
klienciBindingSource.DataSource = obj;
db.Klienci.Attach(klienciBindingSource.Current as Klienci); // here error occurs
}
}
I have tried following replaces for attaching:
db.Entry(klienciBindingSource.Current as Klienci).State = System.Data.Entity.EntityState.Unchanged;
db.Entry(klienciBindingSource.Current as Klienci).State = System.Data.Entity.EntityState.Modified;
But it didn't work out for me
I am using the WPF DocumentViewer to preview an XPS document in my application. The code is actually converting from PDF to XPF actually. When I scroll down during preview, it behaves as expected. However, the moment I reach the point where the second page must appear I get the error:
(Dispatcher): [System.NotImplementedException: This method is not implemented by this class.
at System.Net.WebRequest.BeginGetResponse(AsyncCallback callback, Object state)
at System.IO.Packaging.PackWebRequest.GetResponse()
at MS.Internal.WpfWebRequestHelper.GetResponse(WebRequest request)
at MS.Internal.WpfWebRequestHelper.GetResponseStream(WebRequest request, ContentType& contentType)
at System.Windows.Documents.PageContent._LoadPageImpl(Uri baseUri, Uri uriToLoad, FixedPage& fixedPage, Stream& pageStream)
at System.Windows.Documents.PageContentAsyncResult.Dispatch(Object arg)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)].
I don't understand the WebRequest because I am working in a closed network where there is no Internet allowed. I do not need it for the preview.
My code is below. Some code was written from information coming from this post. I was originally getting an error described in that post which seems to be fixed, but now I am getting the above error and cannot figure out why. The error says that a "method is not implemented" but do not know which method it is talking about. It looks like it is making an asynchronous call when I scroll. Can someone explain what it is doing and how to proceed?
public void PreviewDocument()
{
m_documentService = GcsIocContainer.Instance.Container.Resolve<IDocumentService>();
var xpsDocument = m_documentService.ConvertPdfToXps(Convert.FromBase64String(PdfBase64String));
FixedDocumentSequence fixedDocumentSequence = GetFixedDocumentSequence(xpsDocument);
m_nativeDocumentViewer.Document = fixedDocumentSequence;
}
public class MemoryStreamUri : IWebRequestCreate
{
public WebRequest Create(Uri uri)
{
return new MemoryStreamRequest(uri);
}
}
public class MemoryStreamRequest : WebRequest
{
private Uri _uri;
public MemoryStreamRequest(Uri uri)
{
_uri = uri;
}
public override Uri RequestUri
{
get { return _uri; }
}
public override int Timeout
{
get { return System.Threading.Timeout.Infinite; }
}
}
private FixedDocumentSequence GetFixedDocumentSequence(byte[] xpsBytes)
{
Uri packageUri;
XpsDocument xpsDocument = null;
var memURi = new MemoryStreamUri();
WebRequest.RegisterPrefix("memorystream", memURi);
using (MemoryStream xpsStream = new MemoryStream(xpsBytes))
{
using (Package package = Package.Open(xpsStream))
{
packageUri = new Uri(#"memorystream://" + Path.GetFileName(Guid.NewGuid().ToString()) + ".xps");
try
{
PackageStore.AddPackage(packageUri, package);
xpsDocument = new XpsDocument(package, CompressionOption.Maximum, packageUri.AbsoluteUri);
return xpsDocument.GetFixedDocumentSequence();
}
catch (Exception ex)
{
var msg = ex.Message;
return null;
}
finally
{
if (xpsDocument != null)
{
xpsDocument.Close();
}
PackageStore.RemovePackage(packageUri);
}
}
}
}
I have a property in my viewmodel whose sole job is to send out a message when the property is changed. I wanted to unit test that it was indeed doing it's job so I wrote the following test
[TestFixture, RequiresSTA]
public class ToolBarViewModelTests
{
private SecondaryScalingMode _SecondaryScalingMode;
private void RecordSecondaryScalingSetting(SecondaryScalingMode obj)
{
_SecondaryScalingMode = obj;
}
[Test]
public void AssertCombineAllCornersScalingMessageIsSent()
{
var vm = CreateNewToolBar();
_SecondaryScalingMode = SecondaryScalingMode.IndividualCorner;
AppMessages.SetSecondaryScalingMode.Register(this, (Action<SecondaryScalingMode>)RecordSecondaryScalingSetting);
vm.CombineAllCornersScaling = true;
Assert.IsFalse(vm.IndividualCornerScaling);
Assert.IsFalse(vm.LeftRightScaling);
Assert.IsFalse(vm.FrontRearScaling);
Assert.IsTrue(vm.CombineAllCornersScaling);
Assert.AreEqual(SecondaryScalingMode.CombineAllCorners, _SecondaryScalingMode);
}
}
This test asserts the correct behavior, but it occassionally fails both locally and on my build server due to a threading error. The error is as follows
Test(s) failed. System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
----> System.InvalidOperationException : The calling thread cannot access this object because a different thread owns it.
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
Is there a better way I can write this test that would prevent it from failing randomly in this way?
OK this is the approach I usually take. This is pretty close to what you do.
Keep in Mind you can also highjack the Messenger and subscribe to the Messenger In the unit test.
I posted a simplified version of your code to match to example.
I used to have also some occansionly strange errors in my unit tests and it was a timing/thread issue...
for that it helped to reset the Messenger foreach Unit test...
This is the viewmodel (simplefied guess work =) ... ):
public class UnitTestViewModel:ViewModelBase
{
public UnitTestViewModel()
{
Messenger.Default.Register<string>(this, "SetSecondaryScalingMode", (message) =>
{
UpdateScalingMode();
});
}
private bool _CombineAllCornersScaling;
public bool CombineAllCornersScaling
{
get {
return _CombineAllCornersScaling;
}
set {
_CombineAllCornersScaling = value;
Messenger.Default.Send<string>("update", "SetSecondaryScalingMode");
RaisePropertyChanged("CombineAllCornersScaling");
}
}
private bool _IndividualCornerScaling;
public bool IndividualCornerScaling
{
get
{
return _IndividualCornerScaling;
}
set
{
_IndividualCornerScaling = value;
RaisePropertyChanged("IndividualCornerScaling");
}
}
private bool _LeftRightScaling;
public bool LeftRightScaling
{
get
{
return _LeftRightScaling;
}
set
{
_LeftRightScaling = value;
RaisePropertyChanged("LeftRightScaling");
}
}
private bool _FrontRearScaling;
public bool FrontRearScaling
{
get
{
return _FrontRearScaling;
}
set
{
_FrontRearScaling = value;
RaisePropertyChanged("FrontRearScaling");
}
}
private void UpdateScalingMode()
{
IndividualCornerScaling = false;
LeftRightScaling = false;
FrontRearScaling = true;
}
}
this is the Unit test (using MSTest but could apply to other packages)...
[TestMethod]
public void UpdaetScalingMode()
{
Messenger.Reset();
var vm = new UnitTestViewModel();
bool updateMessageWasSend = false;
string _thisCanBeTheObjectYouWerePassing = String.Empty;
Messenger.Default.Register<string>(vm, "SetSecondaryScalingMode", (msg) =>
{
_thisCanBeTheObjectYouWerePassing = msg;
updateMessageWasSend = true;
});
vm.CombineAllCornersScaling = true;
Assert.AreEqual(true, updateMessageWasSend);
Assert.AreEqual(false, vm.IndividualCornerScaling);
Assert.AreEqual(false, vm.LeftRightScaling);
Assert.AreEqual(true, vm.CombineAllCornersScaling);
Assert.AreEqual("update", _thisCanBeTheObjectYouWerePassing);
}
Rember this is simplyfied to show the concept.
I did just passed a string for message payload but this can be as complex as you want with all messenger functionalities....
I hope this helps... and otherwise it would be helpful to see the ViewModel code to cum up with another test strategy ...
P.S.: I also developed the habit to have 1 assertion per Test only and write more tests instead...
I am using the technique described here to add Groups of my radio buttons to my C# winforms application.
The technique works beautifully until I try a radio button with a tag greater than 9.
In this case an error occurs when i click the radio button
System.InvalidOperationException was unhandled HResult=-2146233079
Message=DataBinding cannot find a row in the list that is suitable for
all bindings. Source=System StackTrace:
at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object
component, Object value)
at System.Windows.Forms.BindToObject.SetValue(Object value)
at System.Windows.Forms.Binding.PullData(Boolean reformat, Boolean force)
at System.Windows.Forms.Binding.Target_PropertyChanged(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at SBD.VivSnap.UI.RadioGroupBox.radioButton_CheckedChanged(Object sender,
EventArgs e) in
e:\EShared\devnet10\VivSnap\SnapInUI\RadioGroupBox.cs:line 70
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.RadioButton.OnClick(EventArgs e)
at System.Windows.Forms.RadioButton.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at SBD.VivSnap.Main.Form1.btnForm1Go_Click(Object sender, EventArgs e) in e:\EShared\devnet10\VivSnap\Main\Form1.cs:line 36
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at SBD.VivSnap.Main.Program.Main() in e:\EShared\devnet10\VivSnap\Main\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart() InnerException:
My code for binding the property is
groupBox.DataBindings.Add("Selected", dataSource, PrinterTypeNum, false, DataSourceUpdateMode.OnPropertyChanged);
My code for the property is
public int PrinterTypeNum
{
get
{
try
{
return (int)this.PrinterType;
}
catch (Exception)
{
return 0;
}
}
set
{
try
{
this.PrinterType = (jtVivPrinterEnum)value;
// the enum goes from 0 to 15
}
catch (Exception)
{
this.PrinterType = jtVivPrinterEnum.jtVivPrinterUnknown;
throw;
}
}
}
public jtVivPrinterEnum PrinterType { get; set; }
**
[Update] I just discovered that I do not get the error if the property is just as follows.
public int PrinterTypeNum { get; set; }
My Radio Group class is as follows
//Best way to databind a group of radiobuttons in WinForms
public partial class RadioGroupBox : GroupBox
{
public RadioGroupBox()
{
this.InitializeComponent();
}
public event EventHandler SelectedChanged = delegate { };
int _selected;
public int Selected
{
get
{
return this._selected;
}
set
{
int val = 0;
var radioButton = this.Controls.OfType<RadioButton>()
.FirstOrDefault(radio => radio.Tag != null
&& int.TryParse(radio.Tag.ToString(), out val) && val == value);
if (radioButton != null)
{
try
{
radioButton.Checked = true;
this._selected = val;
}
catch (Exception ex)
{
Debug.Print(ex.ToString());
throw;
}
}
}
}
protected override void OnControlAdded(ControlEventArgs e)
{
base.OnControlAdded(e);
var radioButton = e.Control as RadioButton;
if (radioButton != null)
radioButton.CheckedChanged += this.radioButton_CheckedChanged;
}
void radioButton_CheckedChanged(object sender, EventArgs e)
{
var radio = (RadioButton)sender;
int val = 0;
if (radio.Checked && radio.Tag != null
&& int.TryParse(radio.Tag.ToString(), out val))
{
this._selected = val;
this.SelectedChanged(this, new EventArgs()); // raises error when val=10
}
}
}
I got this error when I changed the .Visible property to false in one of data bound components.
The work around is to Remove DataBindings on controls before changing their .Visible property to false, then adding the DataBindings back when making them visible again.
Here is code to illustrate the error and how to work around it:
void SetupStuff()
{
BindingSource myBindingSource = new BindingSource();
// Retrieve my data into a DataTable and add it to the BindingSource
DataTable myDataTable = GetMyDataTable();
myBindingSource.DataSource = myDataTable.DefaultView;
// Add DataBindings to Visible components only
myTextBox.Visible = true;
myTextBox.DataBindings.Add("Text", myBindingSource, "MySecret");
}
void UpdateStuff()
{
// Update the currently selected data record
myDataTable.DefaultView[myBindingSource.Position].BeginEdit();
myDataTable.DefaultView[myBindingSource.Position]["MySecret"] = "Top Secret Meetup " + DateTime.Now.AddDays(1).ToString();
myDataTable.DefaultView[myBindingSource.Position].EndEdit();
myDataTable.DefaultView[myBindingSource.Position].AcceptChanges();
// if myTextBox.Visible, then we can see the message
}
void HideStuff()
{
myTextBox.Visible = false;
UpdateStuff();
// After myDataTable..AcceptChanges(), DataBindings are now BROKEN!
// This Cleared all data from controls bound to myBindingSource
try
{
myBindingSource.ResetCurrent();
}
catch (Exception brokenBindingSource)
{
Console.WriteLine("DataBinding broken" + brokenBindingSource.Message);
}
}
void HideStuff()
{
if (myTextBox.Visible)
{
myTextBox.DataBindings.Remove("MySecret");
myTextBox.Visible = false;
}
UpdateStuff();
// After myDataTable..AcceptChanges(), DataBindings are now BROKEN!
// This Cleared all data from controls bound to myBindingSource
try
{
myBindingSource.ResetCurrent();
}
catch (Exception brokenBiSo)
{
Console.WriteLine("DataBinding is broken" + brokenBiSo.Message);
}
}
void ShowStuff()
{
// If I want to make the component visible again, do this:
if (!myTextBox.Visible)
{
myTextBox.Visible = true;
myTextBox.DataBindings.Add("Text", myBindingSource, "MySecret");
}
}
The problem was because I had another property bound that depended on the value selected.
I had "Machine.Mode" as a bound property where the type of the Machine property depended on the PrintType property
I have a dynamically generated hyperlink which when clicked should open a lotus notes document. I do it using the code below.
HyperlinkButton hlb = new HyperlinkButton();
hlb.SetBinding(HyperlinkButton.ContentProperty, new Binding("Properties[" + col.DisplayField + "]"));
hlb.SetBinding(HyperlinkButton.NavigateUriProperty, new Binding("Properties[" + col.LinkField + "]"));
hlb.Click += new RoutedEventHandler(hlb_Click);
RootGrid.Children.Add(hlb);
this is the code that fires when the link is clicked.
static void hlb_Click(object sender, RoutedEventArgs e)
{
HyperlinkButton hlb = (HyperlinkButton)sender;
var hostingWindow = HtmlPage.Window;
hostingWindow.Navigate(hlb.NavigateUri);
}
the lotus notes document opens correctly but I get a System.InvalidOperationException, the details of which are given below
Description: Failed to navigate to notes://<path to the document>
Stacktrace:
at MS.Internal.NavigationHelper.Navigate(Boolean checkUserInitiatedAction)
at System.Windows.Controls.HyperlinkButton.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)
Another interesting thing to note is that it is raised on another thread and hence is not caught when the hostingWindow.Navigate method is fired.
Any ideas ?
Using Silverlight 5, I wrapped the call to open the Lotus Notes doc link within a task and was able to open the link without generating an error.
private void TryOpenDocLink()
{
TaskScheduler ts = TaskScheduler.Default;
Task<bool> task = OpenDocLink();
task.ContinueWith(t =>
{
if (t.Exception != null)
{
this.SetError(t.Exception.Message, enMessageLevel.Error);
}
});
}
private Task<bool> OpenDocLink()
{
TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
try
{
var hostWindow = HtmlPage.Window;
hostWindow.Navigate(new Uri(DocLinkPath));
tcs.SetResult(true);
}
catch (Exception)
{
tcs.SetResult(false);
}
return tcs.Task;
}
Try marking the click event as handled:
static void hlb_Click(object sender, RoutedEventArgs e)
{
e.Handled = true;
HyperlinkButton hlb = (HyperlinkButton)sender;
var hostingWindow = HtmlPage.Window;
hostingWindow.Navigate(hlb.NavigateUri);
}
I'm not sure that this will fix the issue. The error is coming from the click event code inside the hyperlink button. You can tell because that code uses the NavigationHelper class while the Window.Navigate method does not.
Is there a reason you're not just letting the hyperlink button do the navigation?