SqlConnection exception thrown by WPF but not by WebSite? - c#

I have this project, which consists of a WCF Library acting as a Server for a Trouble Ticket system.
Link for solution skeleton: http://imgur.com/eZqe5Q8
I have an interface that allows me to access the server methods.
I have a DB as you can see in the picture, called "MainDB".
I have a website with a service reference to the server which works perfectly fine.
Then I needed to create a GUI application client that accesses the same server interface. I did this by creating a WPF application. I reference the server, just the same as I did in the website and use the same interface, and I call the exact same method, in this case the Login method, which you can check in this image: http://imgur.com/3PajH3U
But when I call this method from the WPF I get an exception on the red squared line which says this:
"An unhandled exception of type 'System.NullReferenceException' occurred in TTService.dll
Additional information: Object reference not set to an instance of an object."
I thought it might be because of the DB not being "published", but it was. I run the website and the WPF at the same time and one runs perfectly smooth while the other causes that exception. I can't get what's causing this, probably because I'm still not experienced in this technology.
The fact that the origin of the method call is different doesn't seem to me like a plausible cause because I can't understand how the method would know where the call originated.
I'm sorry I can't put the images in the post but not enough reputation yet.
Thank you for any help.

I fixed this. It actually was the Interface implementation that was wrong. Sorry for the misinformation.

Related

How to Debug "Source Not Available" WPF error

I have a WPF application that has started failing with the following error at start:
System.InvalidOperationException: ''{DependencyProperty.UnsetValue}' is not a valid value for property 'BorderBrush'.'
This exception was originally thrown at this call stack:
[External Code]
This is not very forthcoming about what has caused the error. I have tried turning on the CLR Exceptions and restarting as per This Page, but it did not give any more information; I turned on the disassembly, but don't understand what it means. Turning on "Just My Code" debugging and all the Exception Settings as per this page got slightly more in the exception stack trace:
System.InvalidOperationException
HResult=0x80131509
Message='{DependencyProperty.UnsetValue}' is not a valid value for property 'BorderBrush'.
Source=WindowsBase
StackTrace: at System.Windows.DependencyObject.GetEffectiveValue(EntryIndex entryIndex, DependencyProperty dp,
RequestFlags requests)
This exception was originally thrown at this call stack:
System.Windows.DependencyObject.GetEffectiveValue(System.Windows.EntryIndex, System.Windows.DependencyProperty, System.Windows.RequestFlags)
but none of this gives me (that I can see) any information about what code is failing. I have got down to deleting various bits and re-starting the app, but it is extremely time-consuming and I can't help but wonder - is there something else I should be doing.
Is there any way I can find out which bit of code is failing, or any clues (e.g. search terms to look for in my code, clues as to whether it would be a .xaml or a .cs page, places to look in the Exception details, anything) that might help narrow down the location? For instance, is this something that would only be returned by a failed attempt to override the template defaults in wpf, or might it be caused by one of my windows - Is it likely to have come from a style maybe?
Basically, other than seeing that there seems to be a place where I should be setting the BorderBrush and am not, I have no idea how to find what error I need to fix - and since it is a missing thing, I don't know how to find it. Any leads, hunches or advice will be greatly received!
This is a WPF Windows Application, writing in Visual Studio 2019 using .NET 4.8
So it turns out that there really is no way to find out clearly where the error was, but through a process of deleting files, clearing out references and reinstating, I was able to find the problem.
There was a reference to a static resource in a connected .DLL that no longer existing since the .DLL was republished without checking. The change in name there meant that a resource was not found and the unset value was sent to the Dependency Property. It would be lovely if Microsoft were able to provide some sort of check on the location of problematic resources.

ExchangeService FindAppointments returns 'This property was requested, but it wasn't returned by the server' error

I'm using Microsoft.Exchange.WebServices.dll version 15.0.847.30 to interact with functions in Outlook. I am using this call:
EWSData = CurrentEmail.FindAppointments(WellKnownFolderName.Calendar, new CalendarView(t, t.AddDays(1)));
(where t is today +/- however many days the user has clicked from today) which passes the WellKnownFolderName and the CalendarView directly through to a call to ExchangeService.FindAppointments.
I have a couple clients who each have a single user who is getting the 'This property was requested, but it wasn't returned by the server' error on some days and not others. Sometimes it pulls in the first few appointments for a day and leaves off the rest. My email, creating appointments, and add/remove contacts functions are all working for them.
I've traced through the ews-managed-api code from github and found the error is thrown when a property is requested but is null. I'm assuming the code on github is much newer than the version I'm using, but if the error is still caused by that code is in my version, I do not know how to find out what properties are causing the issue.
Since I'm not requesting anything specific but using the generic call with the folder name and a date, I'm quite confused as to what properties would be null and why.
What can I do, without re-compiling my application, to track down the problem properties?
Just a thought: do you have a way of tracing the XML flow between your app and Exchange, e.g. Fiddler? On the error response, you may be able to plow into the XML and see the name of the property causing the issue. Not 100% sure on this, but about the only tactic you can try without rebuilding you app with more diagnostic code in there.

NotSupportedException thrown when instantiating a DataContext on wp8

I'm currently using VS2012 Express, writing in C#, and targeting WP8. My testing is being done with the emulator.
I've been following the example here: http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202860(v=vs.105).aspx#BKMK_UsingtheDatabase
My problem is, every time I try to instantiate a DataContext object (well, my derived class) I get a NotSupportedException in System.Data.Linq.ni.dll. The line throwing the exception is the constructor calling base(ConnectionString).
Any idea what I'm doing wrong, or how I can get more information to help me sort this out?
Apparently db files can only use SDF extensions. When I modified the name of my data file to use .SDF, everything worked fine.

Use of Forest.GetCurrentForest in RODC environment

I've got a problem with using Forest.GetCurrentForest() method when communicating with a Read-only domain controller.
The exception thrown is:
System.DirectoryServices.ActiveDirectory.ActiveDirectoryServerDownException: The server is not operational.
Note: Everything works fine when communicating with a RWDC.
Previously, to fix other issues when communicating with a RODC, we had to modify the way we created DirectoryEntry objects, making use of the AuthenticationType.ReadOnlyServer flag. However I've seen (using reflector) that the GetCurrentForest() method creates its own DirectoryEntry object using a Utils class, which in turn uses a DefaultAuthType.
So, my question is: Does anyone know how to set/modify the DefaultAuthType so that it can return the required authentication type? Is there a better way to do this? The aim of this piece of code is simply to get the list of available domains visible to the server.
Thanks,
Ben
Well, doesn't seem like there's an easy answer to this. In the end we rewrote the code to not use the Domain/Forest objects...
What I do to "overcome" this issue was, I first try to get the Forest.GetCurrentForest(), and if exception thrown, I then use Domain.GetComputerDomain() for last solution, of cause, the list now only contain the domain that the web server joined.

MSMQ not invoking COM

I made a COM object with c# and let VS register it for me. I can see it in registry and if I make a test app I can add a reference to it and it works as expected with all the methods available and functional.
Now If I try and use it in a MSMQ rule nothing happens. It will not be invoked. Is this because it is a .NET assembly? Is it because I do not have VS Pro? Do you have any idea at all?
You haven't by any chance registered your component on a mapped network drive have you? MSMQ runs in a different WinStation to the interactive WinStation. Network drives that are mapped in the interactive WinStation are not visible in other WinStations which could result in the symptom you described (component not found).
You need to check the system event log for error messages (eventvwr.exe). If your component is registered and MSMQ is properly configured to activate your component but it fails, most likely the problem is with permissions. The event log should contain the details of the prolem.
Update!!!
I was messing around with this again. I created a simple EXE to fire when a message is received. It accepts 2 string parameters.
I forgot to pass the parameters the first time and I get the SAME error as I was discribing before. About the COM object not being found. I passed the parameters and it worked fine.
I thought I was passing the parameters to my COM object just fine, but maybe not. Maybe I'm doing something wrong. I will create a COM with no parameters and see if I can force the COM to invoke.
If anyone as examples of creating objects to accept parameters, please let me know.

Categories

Resources