|
I do. TO all.
StackOverflow is uncatchable, at least in UWP. Sorry if that wasn't clear in my message, I thought the fact that Visual Studio debugger just CANT stop and break on them would have been enough of an indication....
|
|
|
|
|
Upvoted: that kind of advice is "worth its weight in gold" !
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
Can anyone volunteer a 3D printer that does marble or granite stones to print the post for Bill?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
sadly it is useless advice...
Just checked this barely modified samples... does not work,...
Task.Factory.StartNew(async () =>
{
Thread.CurrentThread.Name = "BackgroundJsonLoader_C71B0546796D46A894925EAF6A0CF420";
Debug.WriteLine(Thread.CurrentThread.Name);
await Task.Delay(10);
Debug.WriteLine(Thread.CurrentThread.Name);
}).Wait();
In fact.. this snippet will be more instructive:
Task.Run(async () =>
{
Console.WriteLine("ThreadID: " +Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("TaskId: " + Task.CurrentId);
await Task.Delay(10);
Console.WriteLine("ThreadID: " + Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("TaskId: " + Task.CurrentId);
}).Wait();
modified 28-Apr-18 11:54am.
|
|
|
|
|
Sadly this is a poor,misleading and contrived usage of Task.
In task heavy code that won't work, for the simple reason that as soon as and every time one write await the next line is, potentially, on another thread...
i.e. check that out
Task.Factory.StartNew(async () =>
{
Thread.CurrentThread.Name = "BackgroundJsonLoader_C71B0546796D46A894925EAF6A0CF420";
Debug.WriteLine(Thread.CurrentThread.Name);
await Task.Delay(10);
Debug.WriteLine(Thread.CurrentThread.Name);
});
In fact.. just try that and understand the magnitude of the problem (not my stackoverflow problem, mind you, the problem of tracking task as they go)
Task.Run(async () =>
{
Console.WriteLine("ThreadID: " +Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("TaskId: " + Task.CurrentId);
await Task.Delay(10);
Console.WriteLine("ThreadID: " + Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("TaskId: " + Task.CurrentId);
}).Wait();
}
modified 28-Apr-18 11:53am.
|
|
|
|
|
Haha, yes, those new shortcuts to do async work are hiding some details. That's not a problem; you choose to write it like that
I don't see the example generating a stackoverflow though; that's more the territory of untamed recursion.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Yes indeed! Now you know!
Anyway, my problem is to stop on StackOverflowException...
News Flash: just did a small UWP test, and VisualStudio2017 did automatically break in the stack overflow exception I purposely generated...
Mmm.. strange, for some reason it doesn't do that at work. At least not on the exception crashing my work app.
|
|
|
|
|
Super Lloyd wrote: Anyway, my problem is to stop on StackOverflowException... Shouldn't be too hard; how many recursive methods are in your app?
Super Lloyd wrote: News Flash: just did a small UWP test, and VisualStudio2017 did automatically break in the stack overflow exception I purposely generated...
Mmm.. strange, for some reason it doesn't do that at work. Just a matter of counting; if you had a log that shows what is executed, you'd have a good start for a breakpoint.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi,
I need your help in my program. I am trying send data to remote server. I have made connection with remote server using TCP/IP it gives response now. But Now, i want to send command to server. it includes my first name, last name as FNAME, LNAME, EMAIL AND HOST-NAME and I am making this program for registration so after that server will return regstration number. when i try to send data it says, 530 command 'fname' command not accepted in this state. Now i don't understand how to bind all data in one string or what format should i use to send data so that i can send it to remote server. Thank you in advance.
Here is my code:
public void Connect(String server)
{
Int32 port = 123;
TcpClient client = new TcpClient(server, port);
string FNAME = "reet";
Byte[] data = System.Text.Encoding.ASCII.GetBytes(FNAME);
NetworkStream stream = client.GetStream();
stream.Write(data, 0, data.Length);
Console.WriteLine("Sent: {0}", FNAME);
data = new Byte[256];
String responseData = String.Empty;
Int32 bytes = stream.Read(data, 0, data.Length);
responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
Console.WriteLine("Received: {0}", responseData);
stream.Close();
client.Close();
}
|
|
|
|
|
The server doesn't understand the data you're sending to it.
You need to consult the documentation for the server to find out what data and commands you need to send.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I know the commands these are FNAME, LNAME, EMAIL, HOST. In FNAME i will pass user first name in FNAME same for last name , email and host. or there is some way to send data to server that i don't know ?
|
|
|
|
|
No ... you did NOT send FNAME, LNAME or anything else remotely connected (pardon).
You sent: "reet".
Nothing more; nothing less.
Listen to the previous advice re: "commands" (and communication "protocols").
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I have a webpage that Is hosted on a IIS-server. When I use Internet explorer to upload files, I get the following error:
<System.Exception: System.Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\brkar1\Downloads\dokumentation.docx'. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)<br />
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)<br />
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)<br />
at System.IO.File.InternalWriteAllBytes(String path, Byte[] bytes, Boolean checkHost) at System.IO.File.WriteAllBytes(String path, Byte[] bytes) at OrderForm.Service.Services.FileService.d__0.MoveNext() in C:\Git-new\devteam\web-applications\ICOM.OrderForm\OrderForm.Service\Services\F
However, If I use firefox, It works just fine.
If I start the project localy in IIS-express, I don't get any exception, but the file Is still not uploaded.
Here Is my code for uploading:
OrderController.cs:
var keys = Request.Form.AllKeys;
var jsonData = Request.Form.Get(keys[0]);
var files = this.Request.Files;
List<FileModel> fileData = new List<FileModel>();
if (files.Count > 0)
{
for (var i = 0; i < files.Count; i++)
{
FileModel fileModel = new FileModel();
HttpPostedFileBase file = files[i];
BinaryReader b = new BinaryReader(file.InputStream);
fileModel.data = b.ReadBytes(file.ContentLength);
fileModel.FileName = file.FileName;
fileData.Add(fileModel);
}
}
var result = await orderService.Create(orderModel, fileData.Count() > 0 ? fileData : null);
Orderservice:
if (files.Count() > 0 && orderNo > 0)
{
var folder = ConfigurationManager.AppSettings["AttachmentFolder"] + "\\" + orderNo;
if (Directory.Exists(folder) == false)
{
Directory.CreateDirectory(folder);
}
foreach (var file in files)
{
FileModel newFile = new FileModel();
var fileName = file.FileName;
var filePath = Path.Combine(folder, fileName);
File.WriteAllBytes(filePath, file.data);
newFile.FileName = fileName;
newFile.FileUrl = filePath;
filesWithPath.Add(newFile);
}
return filesWithPath;
}
ConfigurationManager.AppSettings["AttachmentFolder"] + "\\" + orderNo is just a folder where the file should be saved In.
|
|
|
|
|
IE is probably sending the full path of the file, rather than just the name. Use Path.GetFileName to extract just the file name:
foreach (var file in files)
{
FileModel newFile = new FileModel();
var fileName = Path.GetFileName(file.FileName);
var filePath = Path.Combine(folder, fileName);
... Path.GetFileName Method (System.IO) | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm stumped I have two programs. I'm using the same code in both. It works in one and not in the other. Anybody have any idea what could be causing this?
error:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
tbQ2 was null.
code:
private void Btn1_Checked(object sender, RoutedEventArgs e)
{
Qtype = "LIKE";
Qpre = " '";
Qpost = "%'";
tbQ2.IsEnabled = false;
}
THE XAML code for the wpf is.
<StackPanel Margin="10,0,0,0" Grid.Column="0" Grid.Row="2">
<RadioButton x:Name="Btn1" Content="Starts With" GroupName="QT" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="White" IsChecked="True" Checked="Btn1_Checked"/>
<RadioButton x:Name="Btn2" Content="Contains" GroupName="QT" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="White" Checked="Btn2_Checked" />
<RadioButton x:Name="Btn4" Content="Equals" GroupName="QT" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="White" Checked="Btn4_Checked"/>
<RadioButton x:Name="Btn6" Content="Is Between" GroupName="QT" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="White" Checked="Btn6_Checked"/>
</StackPanel>
And:
<textbox x:name="tbQ2" grid.column="2" horizontalalignment="Left" height="23" grid.row="5" textwrapping="Wrap" text="" verticalalignment="Top" width="111" background="LightBlue" margin="0,3,0,0" isenabled="True">
|
|
|
|
|
jhoga wrote: Object reference not set to an instance of an object... ... is one of the most common questions asked here. It merely means that you are using a variable reference that has not been initialised, either through omission or error. The only way to track it down is by using the debugger to examine all references at the point of failure. In your case the offending variable is tbQ2 , but we cannot guess where it should have been setup, or what other code may have affected it.
|
|
|
|
|
I guess I should have been more detailed in explaining the issue. The code in the two programs are almost identical. I have used this report writer wpf window many times and never had this issue. The xaml code for the checkbox is apparently setting the text box before it is getting initialized in wpf. "OOPs" I think I might have just answered my on question. I hate when that happens.
|
|
|
|
|
Yep, I moved where the text box was in the wpf stack and all is right with the world.
|
|
|
|
|
Hello coomunity!
I'm, once again, facing a little problem. I have a view that puts together different rows from 4 different tables. In my WinForm application I display those in a datagrid view, now I want to delete a row from the datagrid and remove the entry from the view aswell as from two of the tables 'linked' to it. How would I go about this? I've already tried looking for a solution online, though couldn't find anything that did what I need.
P.S. Kinda forgot to mention, that I'm using Entity Framework for the whole apllication.
|
|
|
|
|
|
You delete the rows "from the tables"; "retrieve / reread the view"; and (re)display the view in the grid.
Doesn't matter what "access method" you use.
It's a database "update"; followed by a "refresh" of the ui.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I need to locate a multiline text in a pdf document. I found two possibilitis
ColumnText.ShowTextAligned(writer.DirectContent, Element.ALIGN_LEFT, new Phrase(textPhrase), calculatedX,calculatedY, -rotation);
But when I locate the text this way, I just can see the first line and all other lines get cutted.
TextField tf = new TextField(writer,
new Rectangle(calculatedX, calculatedY, calculatedX + width, calculatedY + height), "");
tf.Text = text;
tf.FontSize = font.Size;
tf.Font = font.BaseFont;
tf.Options = BaseField.MULTILINE | BaseField.READ_ONLY;
tf.TextColor = font.Color;
writer.AddAnnotation(tf.GetTextField());
This works good and I can see all lines but the problem is that i can not set attributes like Bold underline....
Can you please help me to find a way, that I can see all lines and set attributes like bold, underline...
|
|
|
|
|
Describe the tools/libraries you are using to parse/access the pdf file. Describe your development environment.
We cannot read your mind.
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
Hi
I'm having a source code of an Api, but since we don't have to change it. I'm creating a windows service that register it as a COM component then it could be used from the client. I'll try to simplify my issue.
I started with the creation of an interface having the function and an event (that uses delegate)
[Guid(ApiServices.InterfaceId), ComVisible(true)]
public interface IApiServices
{
[DispId(1)]
ApiResult Function1();
[DispId(2)]
event TestEvent event1;
}
Then I created a class that implements this inteface
[
Guid(ClassId), ComVisible(true)
ClassInterface(ClassInterfaceType.None)
ProgId("ApiService")
]
public class ImplApiServices : MarshalByRefObject, IApiServices
{
private ApiObject _apiObject;
public ImplApiServices ()
{
_apiObject= new ApiObject();
_apiObject.TestEvent += OnEvent1;
}
ApiResult Function1()
{
return _apiObject.Function1();
}
public event TestEvent event1;
private void OnEvent1(object e)
{
if (event1 != null)
event1(e);
}
}
And then I did all the other steps to register it as a COM component and launch use it through a service.
when I call it using a client, it is recognized and the function returns the result perfectly
var _apiServiceObjType= Type.GetTypeFromProgID("ApiService");
var _apiServiceObj= Activator.CreateInstance(_apiServiceObjType);
var result = (ApiResult )_apiServiceObjType.InvokeMember("Function1",
BindingFlags.InvokeMethod, null, _apiServiceObj, null);
But when I want to subscribe a method to the event, I get a null eventInfo in the following instruction and can't go further
EventInfo eventInfo = _apiServiceObjType.GetEvent(event1);
Any link or recommendation that helps with this kind of problem is welcome.
Thanks
|
|
|
|
|
I believe you need to use the GetEvent() with "binding flags":
Quote: An event is considered public to reflection if it has at least one method or accessor that is public. Otherwise the event is considered private, and you must use BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static (in Visual Basic, combine the values using Or) to get it.
Type.GetEvent Method (String, BindingFlags) (System)
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|