|
Then you need to debug why the email requests were not being sent at all. You will need to debug it, set breakpoints and see why code doesn't execute the statement.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Thank you Afzaal Ahmad Zeeshan, I need to learn how to set breakpoints (working on visual studio 2015)and then see why the code is execute the statement. It is realy hard to understand why it is not working, as i mentioned in previous post's the 'resett/forgottenpass is working well......
|
|
|
|
|
Hello. I have this backgroundTask whose output type is Windows Runtime Component .
I have absolutely no idea how to use this backgoundTask in my winform application. Basically this backgroundTask gets geolocation and retrieves long/lat. Here is the skeleton for reference
public sealed class LocationBackgroundTask : IBackgroundTask
{
async void IBackgroundTask.Run(IBackgroundTaskInstance taskInstance)
{
BackgroundTaskDeferral deferral = taskInstance.GetDeferral();
try
{
}
catch(Exception ex) { }
finally
{
deferral.Complete();
}
}
}
Again, I have no idea how do I use this runtime component from my winform application (a button will invoke this). This code is in one project and my winform application is second project.
Thanks for any input
|
|
|
|
|
Where did you find that code, or API? That requires you to involve Windows Runtime with Windows Forms? Although I am not saying that WinRT and .NET do not go well, they do and that is the beauty of C# itself.
But, what I wanted to know was, why would you need to do that, when there are many easy cases? Secondly, if an API does expose these types, then it would also expose some wrapper types, too. Are you a bit confused about the term, "component"?
Finally, as I can see, your IBackgroundTask.Run function has a void return type — void can be captured in .NET itself, no need for any Windows Runtime component. That looks like the default Windows Runtime background task interface, you should read a bit more about it here, Background Tasks in Windows Store Apps -- Visual Studio Magazine, it shows a good example of handling these background tasks. That will help you understand how it works.
Anyways, please do read this by Scott Hanselman as well, How to call WinRT APIs in Windows 8 from C# Desktop Applications - WinRT Diagram - Scott Hanselman
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Afzaal Ahmad Zeeshan wrote: Where did you find that code, or API? It is a sample I downloaded somewhere on the web.
Afzaal Ahmad Zeeshan wrote: why would you need to do that, when there are many easy cases? Can you tell me those easy cases? I do not know.
|
|
|
|
|
Django_Untaken wrote: Can you tell me those easy cases? I do not know. One of them would be, to not expose the native typing in either of the cases. Use the types that can be used in both the runtimes.
Since you are writing a background task handler, there is no need to use Windows Runtime background task handler, you can do that in Windows Forms itself using .NET framework's Task API. Which is much more simpler and easier to use.
Task Class (System.Threading.Tasks)
Secondly, if you really do require to have a WinRT component, then make sure it exposes the type that .NET can consume natively; such as returning the string values, integer results etc. Since you only provide an interface implementation, it is very hard to tell what you want to do with that code.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
When my form design interface when editing files close and reopen frmMain.Designer.cs not see the look of the form, press Rebuil ..., press F5 or click Clear Solution no errors, press F5 to run normally, view form, but not the interface design in the form editor mode, in drafting VS screen and press select view designer frmMain.cs it his fault output stream to the attached word file, this case you can go back to the most recent edits or a way to view the form interface design? (Except sit redesigned from scratch) you view attachments error: http://www.mediafire.com/file/3fnke7btqaiab47/Error.doc
|
|
|
|
|
An error in a .doc file? With a description like that?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Instead of writing a stream-of-consciousness and posting it as a question, please try considering us as normal humans, who can't see your screen, access your HDD, or read your mind.
Try again, and use proper sentences and better explanations of exactly what you are doing, what you are seeing, and why it isn't what you wanted. The less you write, the more likely we are to misunderstand you, or not understand at all.
And if you want to show us an error message, copy and paste it into the post - never try to distribute anything via a DOC or DOCX file as these have been known to contain viruses or malicious macros, and it's very unlikely that anyone will download them.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
OriginalGriff wrote: please try considering us as normal humans
Steady on there...
Regards,
Rob Philpott.
|
|
|
|
|
OriginalGriff wrote: considering us as normal humans
I got it covered!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Is this at all possible?
Consider these simplified classes:
static class Class1
{
internal static int GetValue(int First, int Second)
{
return First + Second;
}
}
static class Class2
{
internal static String GetSignatureFromMethod<TResult>(Func<TResult> Method)
{
String SomeCalculatedValue = A calculation depending on the existence of Val1, Val2 + the result of Method();
return SomeCalculatedValue;
}
}
class Program
{
static void Main(string[] args)
{
int Val1 = 3;
int Val2 = 4;
Func<int> Function = () => Class1.GetValue(Val1, Val2);
Console.WriteLine(Class2.GetSignatureFromMethod(Function));
Console.ReadKey();
}
}
I haven't found a way of doing this generically.
My searches indicate that it's not possible to do using reflection, at least not without deep knowledge of IL code.
|
|
|
|
|
No, not like that. By the time your Main gets to Class2.GetSignatureFromMethod the parameter values are no longer on the stack. They just don't exist anymore.
You've picked a very difficult problem that cannot be done without that knowledge of IL. The thing is that you have to grab the parameter values while the code is still in the method that you called. If you call ANY other method while the method your interrogating is running the stack gets deeper and you have to walk the stack to go get the correct parameter values. How far down the stack do you have to go? This is entirely dependent on your interrogation code.
|
|
|
|
|
Thanks for confirming.
Seems I'm stuck with a parameter array and/or a whole load of overloads for the GetSignatureFromMethod.
Or I have to get the architecture changed.
|
|
|
|
|
Not saying it's best for your situation, but you may want to consider using "dynamic" objects, parameter object arrays (like WriteLine()), and / or Name-Value collections for interfacing.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I would have preferred to avoid that kind of solution, but since I can't think of any alternatives...
|
|
|
|
|
If it's "all your code", than I would change all methods to have an "object sender" (and perhaps an "args-type" instance); and "reflect" on that.
Same pattern as the WPF / Windows Forms (ui) event model.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
With a compiled delegate, it's going to be almost impossible.
In your specific example, the Function.Target property will return an instance of an anonymous type, with a field for each captured variable, and one for the delegate:
Function.Target == new
{
Val1 = 3,
Val2 = 4,
Function = Func<int>
}
However, without reading the IL of Function.Method , you have no way of knowing which field corresponds to which argument.
Things get even more interesting if the anonymous closure type is shared between multiple closures, or you're not using a closure at all.
You might be able to extract the information if you use an Expression<Func<T>> [^] instead of a Func<T> . In simple cases, the following seems to work:
Expression<Func<int>> expr = () => Class1.GetValue(Val1, Val2);
var body = (MethodCallExpression)expr.Body;
var parameters = body.Method.GetParameters();
for (int index = 0; index < body.Arguments.Count; index++)
{
var arg = (MemberExpression)body.Arguments[index];
var instance = arg.Expression == null ? null : ((ConstantExpression)arg.Expression).Value;
var field = (FieldInfo)arg.Member;
object value = field.GetValue(instance);
Console.WriteLine("{0} = {1}", parameters[index].Name, value);
}
However, this code is rather fragile, and likely to break if you pass in any "interesting" expressions.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I've meant to respond to this post for a while as it deserves a proper answer, but I had to leave for Germany to go to a funeral so I haven't really had the time until now.
But the very long answer that I thought out boiled down to a very short one in the end.
I'm going to explore the Expression methodology, more for educational purposes than anything else, but since it indeed seems to be quite fragile I'm going for a different architecture for now.
Thanks for the insight!
|
|
|
|
|
Hello,
I think I am level basic at programming, but I'm not lazy to search on internet when I have a problem.
Although I need help because I searched on the internet for hours and when I found something what was looking good, it didn't help me.
And because of that I'm asking you guys if you would help me please. In code's comments are my problems. Thank you for replies.
<pre>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace kg
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
double price = 0;
if (Material.SelectedIndex == 0 && Thickness.SelectedIndex == 0)
price += 82.36;
if (Material.SelectedIndex == 0 && Thickness.SelectedIndex == 1)
price += 125.23;
if (Material.SelectedIndex == 0 && Thickness.SelectedIndex == 2)
price += 163.98;
}
private void Calculate_Click(object sender, EventArgs e)
{
MaterialPriceLabel.Text = price;
}
}
|
|
|
|
|
Member 13010731 wrote: Why is the "price" underlined?
Because you didn't google search "variable scope"
Speed of sound - 1100 ft/sec
Speed of light - 186,000 mi/sec
Speed of stupid - instantaneous.
|
|
|
|
|
You need to learn about variable scope.
3.7 Scopes (C#)[^]
A local variable declared in one method is not available outside of that method. Can you imagine how confusing it would be if that was not the case? If every single local variable had to have a unique name across your entire class or project, so that it didn't conflict with other local variables in other methods?
To make it available to other methods in the same class, make it a field:
public partial class Form1 : Form
{
private double price = 0;
public Form1()
{
InitializeComponent();
if (Material.SelectedIndex == 0 && Thickness.SelectedIndex == 0)
price += 82.36;
if (Material.SelectedIndex == 0 && Thickness.SelectedIndex == 1)
price += 125.23;
if (Material.SelectedIndex == 0 && Thickness.SelectedIndex == 2)
price += 163.98;
}
private void Calculate_Click(object sender, EventArgs e)
{
MaterialPriceLabel.Text = price;
}
}
Fields (C# Programming Guide)[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks, I really appreciate it. You helped me a lot, but when I click button, in the "MaterialPriceLabel" appear 0 every time (there should be for example: 82.36) and I think my "if part" of the code is good. So problem would be in the sending of value to the "price", I think. Can you give me some advice please?
public partial class Form1 : Form
{
private double price = 0;
public Form1()
{
InitializeComponent();
if (Material.SelectedIndex == 0 && Thickness.SelectedIndex == 0)
price += 82.36;
if (Material.SelectedIndex == 0 && Thickness.SelectedIndex == 1)
price += 125.23;
if (Material.SelectedIndex == 0 && Thickness.SelectedIndex == 2)
price += 163.98;
}
private void Calculate_Click(object sender, EventArgs e)
{
MaterialPriceLabel.Text = price.ToString();
}
}
|
|
|
|
|
|
I've got only one problem. I'm trying debug and it works, nevertheless debugging didn't help me.
public partial class Form1 : Form
{
private double price = 0;
public Form1()
{
InitializeComponent();
if (Material.SelectedIndex == 0 && Thickness.SelectedIndex == 0)
price += 82.36;
if (Material.SelectedIndex == 0 && Thickness.SelectedIndex == 1)
price += 125.23;
if (Material.SelectedIndex == 0 && Thickness.SelectedIndex == 2)
price += 163.98;
}
private void Calculate_Click(object sender, EventArgs e)
{
MaterialPriceLabel.Text = cena.ToString();
}
}
Please help me how to get value of price to Calculate_Click.
|
|
|
|