First of all, this is my first post so apologies in advance if I'm neglecting to include anything. Please let me know if I'm doing it wrong.
I'm developing a Windows 8 Store app and having it consume a WCF service I've made. My end goal is to pull data from an SQL database and present in graphs.
For the sake of isolating the problem, I dropped the sql portion (even though the problem exists regardless) and created a table from scratch, so my Service class is as follows:
public class Service1 : IService1
{
public DataSet querySql()
{
try
{
DataSet ds = new DataSet();
DataTable dt = ds.Tables.Add();
dt.Columns.Add("Test", typeof(string));
dt.Rows.Add(1, "Test1");
return ds;
}
From there I attempt to retrieve this data within the windows application like so:
private async void LoadChartContents()
{
// create proxy instance
DatabaseService.Service1Client serviceClient = new DatabaseService.Service1Client();
// async call to wcf method to get returned data
DatabaseService.querySqlResponse ds = await serviceClient.querySqlAsync();
There is more to that method, but it was breaking at the last line of the block I posted.
Here is where I also ran into problems with the debugger. I tried changing a few settings in hopes of getting closer to the problem, but I'm not sure if it helped. When it breaks now I get taken to App.g.i.cs where global::System.Diagnostics.Debugger.Break() is highlighted in
#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException += (sender, e) =>
{
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
};
#endif
The exception in the Locals tab says "Object reference not set to an instance of an object"
InnerException is null, Source is System.ServiceModel, and StackTrace is a hefty:
http://pastebin.com/QiXCPci1
What that looks like is a null pointer exception, but I'm having trouble figuring out where it's occurring
I have a feeling that the ds in DatabaseService.querySqlResponse ds = await serviceClient.querySqlAsync(); is null because that was where it was breaking earlier, but I can't be sure and I can't see why that would be null.
Again, sorry if this isn't clear. Please let me know what other information should be included. Thank you in advance for your help :)
EDIT:
Thanks to gunr2171, I was able to pinpoint the error further. Now it says:
Fatal Exception'1' occurred.
A first chance exception of type 'System.ServiceModel.FaultException'1' occurred in mscorlib.dll
EDIT:
Alas, I am still lost, but I will update this post if I make any progress.
Related
Here is the brief explanation for my script task in SSIS.
Read/Write variable LOGERROR, and it does exist in the Variables panel with string type.
Inside the script, C# code:
try
{
... //what here does is to iterate a folder and move all of them to another folder, codes here are working correctly
Dts.TaskResult = (int)ScriptResults.Success;
}
catch(Exception e)
{
Variables lockedVariables = null;
Dts.VariableDispenser.LockOneForWrite("User::LOGERROR", ref lockedVariables);
lockedVariables["User::LOGERROR"].Value = e.ToString();
lockedVariables.Unlock();
Dts.TaskResult = (int)ScriptResults.Failure;
}
The reason that I manually control the writes of the variable is that the same variable LOGERROR was added to the Event Handler for the same purpose of Point 4.
I direct the Failure to another Execute SQL task, which is trying to insert LOGERROR (Should contain the exception details) into an underlying table.
My questions:
Sometimes the SSISPackage failed at above task (not always, but at almost the same time every day, may have conflicts with the other jobs?) for not any apparent reasons (at least for now). That's why I would like to track what exactly the issue is, but if I query the target logging table. The details does not show anything, just empty.
And, I have a general logging task in Event Handler that logged all the message when task ran with errors. And that message shows nothing but Exception has been thrown by the target of an invocation.
Did I miss something when trying to log LOGERROR? Because it seems for me that the script did not go into the Try & Catch, just failed directly, otherwise it should store the Exception details. (Please correct me if I am wrong). Or, how could I track the error details?
After some investigations, I think the issue was caused by SQL Server Agent failed to access the shared folder during certain time frame.
Possible solution to my questions:
https://social.technet.microsoft.com/Forums/azure/en-US/988207fe-5a25-4da7-a8df-a38fada703da/ssis-script-task-exception-has-been-thrown-by-target-of-invocation?forum=sqlintegrationservices
Im using a Request System called xNet and it seems ObjectDisposedExceptions are occuring which on-occurence causes a HUGE cpu spike, sometimes continuously keeping CPU at 99-100% causing freezes and lag.
The script mentioned is the following:
https://github.com/PR4GM4/xNet-Ameliorated
An example code is:
using (HttpRequest httpRequest = new HttpRequest()) {
string url = "https://httpbin.org";
string[] proxysplit = proxy.Split(':');
httpRequest.Proxy = new InternalProxyClient(ProxyType.HTTP, proxysplit[0], int.Parse(proxysplit[1]), null, null);
httpRequest.UserAgent = Http.ChromeUserAgent();
httpRequest.KeepAlive = true;
httpRequest.ConnectTimeout = 15000;
httpRequest.AllowAutoRedirect = true;
HttpResponse hr = httpRequest.Start(HttpMethod.GET, new Uri(url, UriKind.Absolute), new StringContent(""));
if (hr == null) return "2";
string sr = hr.ToString();
if (sr == null) return "2";
}
(If a list of half/dead proxies are needed, I can provide it, just im not sure if linking to them is allowed or not.)
Big note here, it seems to only ever occur whenever theres some kind of other exception like failing to connect to the proxy, or a general bad response, so good connection proxies and/or no proxy at all never has this issue (unless again a general failed error).
If you loop this code, and give it a dead proxy (And to speed things up, multi-thread it to around 5 a time) it will eventually cause an exception like bad response or a timeout and eventually an objectdisposedexception.
I tried debugging in Visual Studio but it gives me almost no information, Historical Debugging gives no information just "Source not found".
Call Stack for the First Exception Thrown of the ObjectDisposedException in the screenshot above.
Seems to be related to line 1430 in ~Http/HttpRequest.cs or line 217 in ~Proxy/ProxyClient.cs as it's the only line I know to exist thats to do with EndConnect socket and also coincidentally can produce ObjectDisposedException. Just not sure how to properly handle the exception here without causing the rest of the script to fail. Also why does a simple exception here cause so much CPU spike?
Strangely enough, no matter how I wrap an exception handler for ObjectDisposedException it never gets triggered, no matter how much code or where I wrap? (On both scripts)
try
{
tcpClient.EndConnect(ar);
}
catch (Exception ex)
{
connectException = ex;
}
I found out why, it wasnt because of the .EndConnect on either of the 2 files, it was actually caused by the .Close() calls, since it does .EndConnect inside of that, thats why I couldnt see any "Source" etc.
So it was causeed because the socket connection wasnt connected, so doing .Close() would cause the Exception.
It was a simple fix.
(Where tcp = a TcpClient)
Do the following instead of just tcp.Close()
On Timeouts (Where it's most likely if never at all connected):
if (tcp.Client.Connected) {
tcp.GetStream().Close();
tcp.Close();
}
When it might be properly connected:
if (!tcp.Connected) {
if (tcp.Client.Connected) tcp.GetStream().Close();
tcp.Close();
}
I have a huge problem here at the moment. It happens to me when I try to bind to dictionaries, do reflection or like in this case use transitions.
When I try to start the app I get the following error:
Unable to activate Windows Store app [App-Name here]. The activation request failedith error 'Windows was unable to communicate with the target application. This usually indicates that the target application's process aborted. More information may be available in the Debug pane of the Output windows (Debug->Windows->Output).
See help for advice on troubleshooting the issue.
The Output windows does not offer any further information regarding the issue. In fact it even says that the app launched properly.
I have already checked like every blog or forums-entry on the internet but nothing seems to help. I have reinstalled my VS 2012 and the error still occurs. In this case, the following code causes the error (regardless of which transition I use on what element)
<StackPanel.ChildrenTransitions>
<PopupThemeTransition/>
</StackPanel.ChildrenTransitions>
I am REALLY out of ideas. In another case the following code caused that crash:
public class PresentColorsView
{
static PresentColorsView ()
{
List<PresentColorsView> ColorsList = new List<PresentColorsView>();
IEnumerable<PropertyInfo> Properties = typeof(Colors).GetTypeInfo().DeclaredProperties;
foreach (PropertyInfo property in Properties)
{
PresentColorsView tmpAddColors = new PresentColorsView();
if (property.Name.Length < 7)
{
tmpAddColors.ColorName = property.Name;
tmpAddColors.Color = (Color) property.GetValue(null);
ColorsList.Add(tmpAddColors);
}
}
AllColors = ColorsList;
}
public string ColorName { get; set; }
public Color Color { get; set; }
public static IEnumerable<PresentColorsView> AllColors { get; set; }
}
I am really out of ideas and don't know what to do anymore. I frequently get this error on stuff I even have copied exactly word or word from a book or something. This is limiting my developing abilities on a high scale!
I really appreciate every piece of advice. I am thinking about downloading VS 2013 and check weather the bug will still occur.
Thank you very much!
Greetings, FunkyPeanut
Most likely your code throws an unhandled exception. You should handle exceptions at least in the Main method, log them or otherwise let yourself know something went wrong.
In the particular piece of code this line is most likely causing the issue:
tmpAddColors.Color = (Color) property.GetValue(null);
If you read the documentation, you'd quickly figure out it says “Returns the property value of a specified object.” The important part being bold. You are passing a null. Hence either GetValue fails immediately, throwing an exception, or the cast to Color throws an InvalidCastException (in case Color is a value type).
I just have got the same error when trying to debug a WPhone App.
Spite of my issue is not related whit this one, and after long time reading threads and trying eveything related with it, i have found where the problem is and I would like to share it.
I had a Dictionary instantiation at main class App.cs. When performing test phases I didn't realized that I have added a duplicate key and this simply raised the error reported on this post.
I'm getting an intermittent error when using Outlook interop within my program. I get users reporting this error every now and then, but it's impossible to reproduce on my end. What's even stranger is that if they restart the program and try again, the error is gone.
Here's the code I'm using to get a reference to Outlook.
public class CommonStuff
{
public static void Initialize()
{
olk = new Microsoft.Office.Interop.Outlook.Application();
olk.ItemSend += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler(OutlookInterop_ItemSend);
}
public static Microsoft.Office.Interop.Outlook.Application GetOutlook()
{
if (Process.GetProcessesByName("OUTLOOK").Count() == 0) //previous attempt at fixing this issue, and i'm not sure if i even need this
{
olk = new Microsoft.Office.Interop.Outlook.Application();
}
return olk;
}
}
And the code that's used when sending the actual email.
public void SendEmail()
{
Microsoft.Office.Interop.Outlook.MailItem eMail = (Microsoft.Office.Interop.Outlook.MailItem)CommonStuff.GetOutlookApp().CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
eMail.Subject = String.Format("Subject");
eMail.To = "email#things.com";
eMail.Companies = "Company";
eMail.Body = "blah blah blah";
eMail.Attachments.Add(GetCrystalReportPDF());
((Microsoft.Office.Interop.Outlook._MailItem)eMail).Display();
}
Unfortunately I don't know where exactly the error is happening because I can't reproduce the bug. Does anyone have any clues as to what's going on?
This is the classic kind of problem with process interop, you get to troubleshoot all of the bugs and crashes of that other process as well. "RPC server is not available" is a very generic error and doesn't mean anything more than "the process doesn't work anymore". A few simple reasons for that, it could simply have crashed or the user terminated it. Outlook is in general a troublemaker, it isn't exactly the most stable program in Office.
Your work-around with Process.GetProcessesByName() is a fair attempt but it is unlikely to work. Users commonly already have Outlook running for their own use, you'll see that instance as well. You can't tell if that process you see is the one that you started and matches your olk instance or is the one that user is looking at.
The proper workaround is to re-create your olk instance when you get the exception. That can be hard to deal with since it might be generated while you are deeply nested in your code. But it is best to not fix that case, because that hints at your code inducing the crash, you don't want to hide that problem. Implement a "canary test", just sniff at an innocent property before you start doing something non-trivial. If that induces the exception then recreate the instance. Do test this, I'm not 100% sure that the old olk instance is going to bomb your program when it gets finalized. You ought to get a repro by killing Outlook.exe with Task Manager.
I'm receiving this error message when trying to return data from a WCF service.
"The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9960000'"
It is misleading because it shows ~59 seconds, but the exception happens is about 2 seconds. The last time I received this error message it had to do with an infinite loop caused by serializing entity framework objects. Luckily, I had just made the change so it was easy to spot.
This time I don't know what changed to cause this. I diffed the entity framework classes to find out there haven't been any changes. As far as I know the database has also stayed the same, although I don't know how to prove that since it's fairly large.
If I step through the WCF code with a debugger, I see that it is correctly gathering data. It even tries to return the information. But, in the client side proxy I receive the exception on this line of code:
return Channel.GetDocuments( user, criterion );
Does anybody have any insight or tools that may help me track down this exception?
I found the problem. It had to do with a column being removed from the database and the entity framework models were not updated. It wasn't a circular loop that I had previously thought.
Here is the trick that pointed me in the right direction.
Client Side Proxy
public List<ImageData> GetDocuments( User user, DocumentSearchCriterion criterion )
{
Channel.GetDocuments( user, criterion );
}
WCF Side Service
public List<ImageData> GetDocuments( User user, DocumentSearchCriterion criterion )
{
List<ImageData> documents = new DocumentRepository().GetDocuments( user, criterion );
// Temporary test to see if we can serialize the data. This is only for debugging
// purposes and needs to be removed from production code.
DataContractSerializer serializer = new DataContractSerializer( documents.GetType() );
using( FileStream stream = new FileStream( "SerializerOutput.xml", FileMode.Create ) )
{
// This line will give an exception with useful details while debugging.
serializer.WriteObject( stream, documents );
}
return documents;
}
Hope that helps anybody else with this generic and misleading exception.
Check the following:
You have a lot of data so you need to extend the timeout in your .config file
Most likely in my experience is that you have a circular reference in the type you are returning from the the WCF function.
so if you have a class that has something like this, WCF will be unhappy
[DataContract]
public class MyClass
{
public ChildObject(int i)
{
}
[DataMember]
public MyClass Parent
{
get;
set;
}
}