Visual Studio SDK Breakpoint2.BreakWhenHit = true throws exception 0x8971101A - visual-studio-2010

The following code produces an exception:
Breakpoint2 breakpoint = ...;
breakpoint.BreakWhenHit = true;
// System.Runtime.InteropServices.COMException (0x8971101A): Exception from HRESULT: 0x8971101A
// at EnvDTE80.Breakpoint2.set_BreakWhenHit(Boolean BreakWhenHit)
However if I set BreakWhenHit to false, there is no exception.
Why does it happen and how do I work around it?

It seems that the operation fails if there is no Message set on breakpoint.
It's weird that it fails on BreakWhenHit = true (breakpoint), but in UI only tracepoints require a message.
Here is my workaround (sets/resets message when required):
private void SetBreakWhenHit(Breakpoint2 breakpoint, bool value) {
var messageStubbed = false;
if (value && string.IsNullOrEmpty(breakpoint.Message)) {
// http://stackoverflow.com/questions/27753513/visual-studio-sdk-breakpoint2-breakwhenhit-true-throws-exception-0x8971101a
breakpoint.Message = "stub";
messageStubbed = true;
}
breakpoint.BreakWhenHit = value;
if (messageStubbed)
breakpoint.Message = "";
}

Related

ZeroMQ NetMQ TrySend always succeeds

public static void ZeroMQ()
{
try
{
TimeSpan timeout = TimeSpan.FromMilliseconds(2000);
AsyncIO.ForceDotNet.Force();
using (PairSocket client = new PairSocket("tcp://127.0.0.1:5555"))
{
client.Options.SendHighWatermark = 0;
client.Options.Linger = TimeSpan.Zero;
bool success = client.TrySendFrame(timeout, "Hello");
Debug.Log($"Success = {success}");
string msg = string.Empty;
success = client.TryReceiveFrameString(timeout, out msg);
Debug.Log($"Success = {success} - {msg}");
success = client.TryReceiveFrameString(timeout, out msg);
Debug.Log($"Success = {success} - {msg}");
}
}
catch (Exception e)
{
Debug.Log(e);
}
finally
{
NetMQConfig.Cleanup();
}
}
Here's some code with two problems:
If I run this code with no server running on :5555, this program prints "Success = true" for the TrySendFrame(), and false for both receives. I would expect it to fail and can't get it to fail even with Linger set to 0 and the high water mark also set to zero.
The second issue is that after the execution hits the finally block, the program freezes forever.
Can someone better versed in ZMQ give me any pointers as to why this might be happening?

Brother Printer SDK in Xamarin.Android Printing Issue

I'm Working on Brother Label Printer QL-710W using Xamarin.Android.
I have created a Android bindings project and Added jar files and .so files as shown below.
I'm using Visual Studio.
Jars >
BrotherPrintLibrary.jar; BuildAction: EmbeddedJar
MobilePrintLib.jar; BuildAction: ReferenceJar
NativeLibraries > armeabi >
libAndrJFPDFEMB.so; BuildAction: EmbeddedNativeLibrary
libcreatedata.so; BuildAction: EmbeddedNativeLibrary
Additions
ClassTest.cs
public bool PrintFile(string fileurl, NetPrinter printer)
{
Task <bool> printTask = new Task<bool>(() => {
bool success = true;
try
{
Printer myPrinter = new Printer();
PrinterInfo myPrinterInfo = new PrinterInfo();
PrinterStatus status = new PrinterStatus();
LabelInfo mLabelInfo = new LabelInfo();
myPrinterInfo.PrinterModel = PrinterInfo.Model.Ql710w;
myPrinterInfo.IpAddress = printer.IpAddress;
myPrinterInfo.MacAddress = printer.MacAddress;
myPrinterInfo.Port = PrinterInfo.PortEnum.Net;
myPrinterInfo.PrintMode=PrinterInfo.PrintModeEnum.FitToPage;
myPrinterInfo.PaperSize = PrinterInfo.PaperSizeEnum.Custom;
myPrinterInfo.Orientation = PrinterInfo.OrientationEnum.Portrait;
myPrinterInfo.LabelNameIndex = LabelInfo.QL700.W62.Ordinal();
myPrinterInfo.ScaleValue = 1;
mLabelInfo.LabelNameIndex = LabelInfo.QL700.ValueOf("W62").Ordinal();
mLabelInfo.IsAutoCut = true;
mLabelInfo.IsEndCut = true;
myPrinter.SetPrinterInfo(myPrinterInfo);
myPrinter.SetLabelInfo(mLabelInfo);
myPrinter.StartCommunication();
status = myPrinter.PrintFile(fileurl);
if (status.ErrorCode != PrinterInfo.ErrorCode.ErrorNone)
success = false;
myPrinter.EndCommunication();
}catch(Exception ex)
{
Console.WriteLine("ERROR : {0}",ex.Message);
success = false;
}
return success;
});
printTask.Start();
var isSuccess = printTask.Result;
return isSuccess;
}
I'm getting printers list successfully from network. But when I'm calling above method it is getting exception at myPrinter.SetPrinterInfo(myPrinterInfo); as "Couldn't load createdata from loader dalvik.system.PathClassLoader[DexPathList[[zip file \"/data/app/PocAndroidArchieve.PocAndroidArchieve-2.apk\"],nativeLibraryDirectories=[/data/app-lib/PocAndroidArchieve.PocAndroidArchieve-2, /vendor/lib, /system/lib]]]: findLibrary returned null"
Please suggest me if any one has idea to work with jar's and dependent .so files.
Thanks in advance.

EWS The server cannot service this request right now

I am seeing errors while exporting email in office 365 account using ews managed api, "The server cannot service this request right now. Try again later." Why is that error occurring and what can be done about it?
I am using the following code for that work:-
_GetEmail = (EmailMessage)item;
bool isread = _GetEmail.IsRead;
sub = _GetEmail.Subject;
fold = folder.DisplayName;
historicalDate = _GetEmail.DateTimeSent.Subtract(folder.Service.TimeZone.GetUtcOffset(_GetEmail.DateTimeSent));
props = new PropertySet(EmailMessageSchema.MimeContent);
var email = EmailMessage.Bind(_source, item.Id, props);
bytes = new byte[email.MimeContent.Content.Length];
fs = new MemoryStream(bytes, 0, email.MimeContent.Content.Length, true);
fs.Write(email.MimeContent.Content, 0, email.MimeContent.Content.Length);
Demail = new EmailMessage(_destination);
Demail.MimeContent = new MimeContent("UTF-8", bytes);
// 'SetExtendedProperty' used to maintain historical date of items
Demail.SetExtendedProperty(new ExtendedPropertyDefinition(57, MapiPropertyType.SystemTime), historicalDate);
// PR_MESSAGE_DELIVERY_TIME
Demail.SetExtendedProperty(new ExtendedPropertyDefinition(3590, MapiPropertyType.SystemTime), historicalDate);
if (isread == false)
{
Demail.IsRead = isread;
}
if (_source.RequestedServerVersion == flagVersion && _destination.RequestedServerVersion == flagVersion)
{
Demail.Flag = _GetEmail.Flag;
}
_lstdestmail.Add(Demail);
_objtask = new TaskStatu();
_objtask.TaskId = _taskid;
_objtask.SubTaskId = subtaskid;
_objtask.FolderId = Convert.ToInt64(folderId);
_objtask.SourceItemId = Convert.ToString(_GetEmail.InternetMessageId.ToString());
_objtask.DestinationEmail = Convert.ToString(_fromEmail);
_objtask.CreatedOn = DateTime.UtcNow;
_objtask.IsSubFolder = false;
_objtask.FolderName = fold;
_objdbcontext.TaskStatus.Add(_objtask);
try
{
if (counter == countGroup)
{
Demails = new EmailMessage(_destination);
Demails.Service.CreateItems(_lstdestmail, _destinationFolder.Id, MessageDisposition.SaveOnly, SendInvitationsMode.SendToNone);
_objdbcontext.SaveChanges();
counter = 0;
_lstdestmail.Clear();
}
}
catch (Exception ex)
{
ClouldErrorLog.CreateError(_taskid, subtaskid, ex.Message + GetLineNumber(ex, _taskid, subtaskid), CreateInnerException(sub, fold, historicalDate));
counter = 0;
_lstdestmail.Clear();
continue;
}
This error occurs only if try to export in office 365 accounts and works fine in case of outlook 2010, 2013, 2016 etc..
Usually this is the case when exceed the EWS throttling in Exchange. It is explain in here.
Make sure you already knew throttling policies and your code comply with them.
You can find throttling policies using Get-ThrottlingPolicy if you have the server.
One way to solve the throttling issue you are experiencing is to implement paging instead of requesting all items in one go. You can refer to this link.
For instance:
using Microsoft.Exchange.WebServices.Data;
static void PageSearchItems(ExchangeService service, WellKnownFolderName folder)
{
int pageSize = 5;
int offset = 0;
// Request one more item than your actual pageSize.
// This will be used to detect a change to the result
// set while paging.
ItemView view = new ItemView(pageSize + 1, offset);
view.PropertySet = new PropertySet(ItemSchema.Subject);
view.OrderBy.Add(ItemSchema.DateTimeReceived, SortDirection.Descending);
view.Traversal = ItemTraversal.Shallow;
bool moreItems = true;
ItemId anchorId = null;
while (moreItems)
{
try
{
FindItemsResults<Item> results = service.FindItems(folder, view);
moreItems = results.MoreAvailable;
if (moreItems && anchorId != null)
{
// Check the first result to make sure it matches
// the last result (anchor) from the previous page.
// If it doesn't, that means that something was added
// or deleted since you started the search.
if (results.Items.First<Item>().Id != anchorId)
{
Console.WriteLine("The collection has changed while paging. Some results may be missed.");
}
}
if (moreItems)
view.Offset += pageSize;
anchorId = results.Items.Last<Item>().Id;
// Because you’re including an additional item on the end of your results
// as an anchor, you don't want to display it.
// Set the number to loop as the smaller value between
// the number of items in the collection and the page size.
int displayCount = results.Items.Count > pageSize ? pageSize : results.Items.Count;
for (int i = 0; i < displayCount; i++)
{
Item item = results.Items[i];
Console.WriteLine("Subject: {0}", item.Subject);
Console.WriteLine("Id: {0}\n", item.Id.ToString());
}
}
catch (Exception ex)
{
Console.WriteLine("Exception while paging results: {0}", ex.Message);
}
}
}

Compiler error when combining Linq + "RangeVariables" + TPL + DynamicTableEntity

I'm looking at the Microsoft-provided sample "Process Tasks as they Finish" and adapting that TPL sample for Azure Storage.
The problem I have is marked below where the variable domainData reports the errors in the compiler: Unknown method Select(?) of TableQuerySegment<DynamicTableEntity> (fully qualified namespace removed)
I also get the following error DynamicTableEntity domainData \n\r Unknown type of variable domainData
/// if you have the necessary references the following most likely should compile and give you same error
CloudStorageAccount acct = CloudStorageAccount.DevelopmentStorageAccount;
CloudTableClient client = acct.CreateCloudTableClient();
CloudTable tableSymmetricKeys = client.GetTableReference("SymmetricKeys5");
TableContinuationToken token = new TableContinuationToken() { };
TableRequestOptions opt = new TableRequestOptions() { };
OperationContext ctx = new OperationContext() { ClientRequestID = "ID" };
CancellationToken cancelToken = new CancellationToken();
List<Task> taskList = new List<Task>();
var task2 = tableSymmetricKeys.CreateIfNotExistsAsync(cancelToken);
task2.Wait(cancelToken);
int depth = 3;
while (true)
{
Task<TableQuerySegment<DynamicTableEntity>> task3 = tableSymmetricKeys.ExecuteQuerySegmentedAsync(query, token, opt, ctx, cancelToken);
// Run the method
task3.Wait();
Console.WriteLine("Records retrieved in this attempt = " + task3.Result.Count());// + " | Total records retrieved = " + state.TotalEntitiesRetrieved);
// HELP! This is where I'm doing something the compiler doesn't like
//
IEnumerable<Task<int>> getTrustDataQuery =
from domainData in task3.Result select QueryPartnerForData(domainData, "yea, search for this.", client, cancelToken);
// Prepare for next iteration or quit
if (token == null)
{
break;
}
else
{
token = task3.Result.ContinuationToken;
// todo: persist token token.WriteXml()
}
}
//....
private static object QueryPartnerForData(DynamicTableEntity domainData, string p, CloudTableClient client, CancellationToken cancelToken)
{
throw new NotImplementedException();
}
Your code is missing a query. In order to test the code I created the following query:
TableQuery<DynamicTableEntity> query = new TableQuery<DynamicTableEntity>()
.Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "temp"));
I also added the method QueryPartnerForData which doesn't do anything (simply returns null) and everything works fine. So maybe it's an issue with the QueryPartnerForData method? The best way to find the actual error is by setting a breakpoint here and there.
A StackOverflowException often means you are stuck in an endless loop. Run through the breakpoints a few times and see where your code is stuck. Could it be that QueryPartnerForData calls the other method and that the other method calls QueryPartnerForData again?

Cannot initialize unordered_map from int

I've got a really strange problem. MSVC doesn't have initializer lists, so I've used a lambda to approximate them.
static const std::unordered_map<std::wstring, LexedFile::Token> reserved_words =
[]() -> std::unordered_map<std::wstring, LexedFile::Token> {
std::unordered_map<std::wstring, LexedFile::Token> retval;
// Do stuff with retval
return retval;
}();
MSVC throws a compiler error.
error C2440: 'initializing' : cannot convert from 'int' to
'std::tr1::unordered_map<_Kty,_Ty>'
Unless I'm quite blind, there's no "int" anywhere near this. I don't see what's wrong. Any suggestions?
Edit:
There's nothing funky about // Do stuff with retval, it's just a bunch of insertions, and this is a function-scope static variable in a lambda in a member function.
auto next = [&] {
static const std::unordered_map<std::wstring, LexedFile::Token> reserved_words =
[]() -> std::unordered_map<std::wstring, LexedFile::Token> {
std::unordered_map<std::wstring, LexedFile::Token> retval;
retval[L"namespace"] = LexedFile::Token::Namespace;
retval[L"for"] = LexedFile::Token::For;
retval[L"while"] = LexedFile::Token::While;
retval[L"do"] = LexedFile::Token::Do;
retval[L"switch"] = LexedFile::Token::Switch;
retval[L"case"] = LexedFile::Token::Case;
retval[L"default"] = LexedFile::Token::Default;
retval[L"try"] = LexedFile::Token::Try;
retval[L"catch"] = LexedFile::Token::Catch;
retval[L"auto"] = LexedFile::Token::Auto;
retval[L"type"] = LexedFile::Token::Type;
retval[L"break"] = LexedFile::Token::Break;
retval[L"continue"] = LexedFile::Token::Continue;
retval[L"return"] = LexedFile::Token::Return;
retval[L"static"] = LexedFile::Token::Static;
retval[L"sizeof"] = LexedFile::Token::Sizeof;
retval[L"decltype"] = LexedFile::Token::Decltype;
retval[L"if"] = LexedFile::Token::If;
retval[L"else"] = LexedFile::Token::Else;
return retval;
}();
if (stack.empty())
return;
std::wstring token(stack.begin(), stack.end());
stack.clear();
if (reserved_words.find(token) != reserved_words.end()) {
l.tokens.push_back(reserved_words.find(token)->second);
return;
}
l.tokens.push_back(LexedFile::Identifier);
};
The compiler will accept it if I use the constructor directly not initialization, which seems very strange. Probably a compiler bug.
Calling the constructor with () instead of using = works just fine, so I'm marking this one as a compiler error.

Resources