|
The only reliable way would be to use a memory profiler. Either CLR Profiler[^] or PerfView[^] should do the job.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you for this, I allready know it.
modified 19-Jan-21 21:04pm.
|
|
|
|
|
Error :The type or namespace name 'Contract_Kind' could not be found (are you missing a using directive or an assembly reference?)
///
/// Gathers values from contract kind checkboxes (Forex, Equity, Options)
///
private IEnumerable<contractkind> GetSelectedContractKinds()
{
if (chbFutures.Checked)
{
yield return Contract_Kind.Future;
yield return Contract_Kind.FutureCompound;
yield return Contract_Kind.GenericCompound;
}
if (chbForex.Checked)
{
yield return Contract_Kind.Forex;
}
}
}
Can somebody help me to fix this ERROR.
David
|
|
|
|
|
The error is fairly self-explanatory - you're trying to use a type called Contract_Kind which doesn't exist.
Either:
- you're missing a reference to the assembly where the type is defined; or
- you're missing a
using statement for the namespace where the type is defined; or - you've got the wrong type name; or
- you haven't written the type.
We can't see your code, so we can't tell you which of those options is the case.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have nested classes Inner class which is inherited by outer class. Inside inner class I have 2 integer properties. Which I use in Outer class to create 2 timer types.
Inner
Elapsed Time
Total Time
Outer class:
Inner inner1
Inner inner2
I use a loop to increment and update elapsed time property on inner1 of the outer class. The property updates, however the onproperty change event does not fire for the Outer class.
How do I bubble up the onproperty change event inorder to trigger the onproperty change event for my outer class.
|
|
|
|
|
This is usually done by creating a delegate and subscribing to the event. There is a tutorial on the subject at Delegates Tutorial (C#)[^].
|
|
|
|
|
rudedog1 wrote: have nested classes Inner class which is inherited by outer class. This does not make sense, please describe what your classes are, and which classes inherit from other classes.
Clarify whether you are talking about the outer class containing instances of the inner classes, or containing the actual definition of the inner classes.
Describe where and how you have implemented property notification change code.
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
I have a class I define as inner class that contains 2 integer properties. This class is a nested class of a outer class which uses the inner class. The inner class is not a base class for the outer class. I am using these classes to create a type of timer. Timer has begin and end fields. I have created a singleton class that will read in information including beginning and end integer values. That will be used to populate the fields of the begin and end properties. The singleton class will increment through the begin and end range and update a textbox on a Form User interface. During the loop in the Singleton if triggers the onproperty change event of the property of the Inner class, however the onproperty change event of the outer class is not triggered. The onproperty change event of the outer class is the one needed to trigger the updates to the UI. I need to trigger the onproperty change event of the property of the outer class, when the onproperty change event of the inner class is triggered, to update my User Interface.
Class Inner
{
int begin;
int end;
public int Begin
{
get {return begin;}
set
{
begin = value;
OnPropertyChanged("Begin");
}
public int End
{
get {return end;}
set
{
End = value;
OnPropertyChanged("End");
}
}
}
Class Outer
{
Inner timer1;
Inner timer2;
public Inner Timer1
{
get {return timer1;}
set
{
timer1= value;
OnPropertyChanged("Timer1");
}
public Inner Timer2
{
get {return timer2;}
set
{
timer2= value;
OnPropertyChanged("Timer2");
}
}
|
|
|
|
|
I'd like to suggest you use the CP editor to format your code so it's more readable.
Also, I do not see your implementation of PropertyChanged notification. This is Windows Forms ... or WPF ?
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
When I create a new empty C# Windows Application project in Visual Studio a form shows up that I can drag and drop components from the toolbox onto and easily change their sizes, locations, default texts, etc. Is this "graphical" way of programming possible to do with a class that, for example, inherits a Panel, GroupBox or similar? How do I do that in that case?
|
|
|
|
|
Yes - if you create a UserControl then when you have next successfully built your project it will appear in the tool box at the top when you open your Form design view.
A UserControl is basically a blank Panel that is ready for you to add what controls and functionality you need to.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thanks. Is it possible to inherit a Panel, GroupBox, etc if I use this techninue? It's not super important that I inherit, but if possible I would like to do so.
|
|
|
|
|
Yes - but for a panel, use the UserControl directly, it's pretty much the same.
You can start it by deriving from any control you like, but the easiest way to do it is to create a UserControl via the VS "Add User Control" project context menu, and then change the control it derives from in the class file once it's created. You may get a couple of compiler errors depending on the control you change to, but they are easy to fix in the designer.cs file.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I need to convert a model to json. I found that it can be done with System.web.script.serialization dll. When i try to add reference, it's not available. how can we add?
|
|
|
|
|
Use Json.NET[^] instead. You can install it via NuGet[^]:
Install-Package Newtonsoft.Json
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
It is available, you're probably just looking in the wrong place.
|
|
|
|
|
my code is :
random r=new random();
while(true)
Console.writeline(r.next(100));
at the beginning,it's run ok, but after a minite, r.next(100) will output 0. i can't understand why it changed?
|
|
|
|
|
|
hi,
r.next(100) ;
0 between 100 random number but 0 include , 100 not
if you do not want to get 0 output , you must change code like this :
r.next(1,100) ;
|
|
|
|
|
Update 08/01/16 - After going back and forth on my end, my IT department resolved the issue. I don't have the specifics on what they did but I believe it was just to whitelist my program.
If I find that it was something different I will update this again.
Thanks everyone who replied.
--------------------
[original post]
I've created a ClickOnce app and one of the menu items launches a separate EXE using the Process.Start() method. The problem I am running into is that the new EXE process is being flagged as a virus (malicious program) by TrendMicro OfficeScan. I assume it is not happy with launching an EXE from another EXE and treats it as malicious.
While I can add an exclusion in OfficeScan, it won't continue to work once there is an update to the ClickOnce app since it creates a new installation folder.
I've done some searching and found nothing so far, or just haven't found the right combination of words to search for.
Has anyone run across this and if so, were you able to resolve it and how?
I'm happy to provide any details.
Thank you in advance.
Mike
modified 1-Aug-16 18:47pm.
|
|
|
|
|
I have no idea why Trend is telling you it's malicious, unless it really has been infected by something, but I can tell you that it's not because you're launching another process.
First, I'd probably do a virus scan specifically on your dev machine.
Then I'd try copying your application to the test machine manually and launching it yourself, without doing it through ClickOnce.
|
|
|
|
|
Thank you for the quick response. I am building both projects myself and the one being called is the NuGet Package Explorer, obtained from their site.
I also found out, since posting this, that my call to nuget.exe results in the same problem.
Neither of those programs have viruses.
I am in the process of combining all of the projects into one EXE which will eliminate the problem; however, I was hoping there was a simpler solution.
Mike
|
|
|
|
|
MichaelC#Noob wrote: I also found out, since posting this, that my call to nuget.exe results in the same problem.
Neither of those programs have viruses.
If that is really the case, then you need to notify TrendMicro OfficeScan of the "false positive" so they can check themselves.
I'd be suspicious though: what did you use to check for an absence of virus, and how? On what machine?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I ran the same TrendMicro scanner on the computer where the code is being run and it shows no viruses found.
|
|
|
|
|
False positive detections do happen. Virus scanners compare your program with some "signatures" of viruses, i.e. some binary snippets. And it may happen that harmless programs share that snippet. Send the program to the anti-virus manufacturer so that they can change their signature library.
|
|
|
|