|
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.
|
|
|
|
|
I agree with your comment but in this case I'm not sure how that would apply. The executable itself does not get flagged as a virus and also runs without issue. It's only a problem when being launched from another application.
|
|
|
|
|
I am trying to send data from a View to be saved in the database.
Below are snippets of code in my Edit View and the EditController method
Edit View
/////////////////////////////////////////////////////////////////
<tr>
<td>@Html.LabelFor(model=>model.Category.ID, "Category")</td>
<td>
@Html.DropDownListFor(model => model.ProductCategories,
ViewBag.categoryList as IEnumerable<SelectListItem>,
(string)ViewBag.ProductCategoryName)
</td>
</tr>
/////////////////////////////////////////////////////////////////
Edit Method in EditController
[HttpPost]
public ActionResult Edit(ProductViewModel pvm)
{
ProductServiceClient psc = new ProductServiceClient();
psc.EditProduct(pvm.Product);
return RedirectToAction("Index");
}
Above is a snippet of the code in the Edit View, users are sent to the Edit View from the Index View when they select the Edit link associated with a product in the Index View.
There are two ViewBags used in populating the dropdownlist in the Edit View.
ViewBag.categoryList contains data from the Product Category which had been added to a IEnumerable<selectlistitem> object.
ViewBag.ProductCategoryName contains a the product category name of the product that the user had selected in the Index View.
Below is my ViewModel
public class ProductViewModel
{
public Product Product
{ get;set;}
public Category Category
{get;set;}
public ProductCategory ProductCategory
{get;set;}
private IEnumerable<SelectListItem> productCategories;
public IEnumerable<SelectListItem> ProductCategories
{
get
{
return productCategories ?? new List<SelectListItem>();
}
set
{
productCategories = value;
}
}
}
The above code is not working, I cannot save the form data when clicking the Save button.
modified 26-Jul-16 1:38am.
|
|
|
|
|
hi .,any one can help me .,
how to set custom notify icon for the notify icon ballontipicon
|
|
|
|
|
|
|
I have joined two objects so that I can access properties of both objects from a single object. I did the join using LINQ then I tried to filter the result using the .Where() and .Single() methods.
I got the error "Object reference not set to an instance of an object." at runtime.
Please take a look at my code below and help explain what I did incorrectly.
public class Product
{
[Display(Name = "ID")]
public int ID { get; set; }
[Display(Name = "Name")]
public string Name { get; set; }
[Display(Name = "Price")]
public decimal Price { get; set; }
[Display(Name = "CategoryID")]
public int CategoryID { get; set; }
}
public class Category
{
[Display(Name = "ID")]
public int ID { get; set; }
[Display(Name = "Name")]
public string Name { get; set; }
}
public void MyMethod(string id)
{
List<Product> _products = new List<Product>();
List<Category> _categories = new List<Category>();
_products = psc.FindAllProducts();
_categories = psc.FindAllCategories();
var _productCategories =
from c in _categories
join p in _products
on c.ID equals p.CategoryID
select new {
p.ID, p.Name, p.Price,
p.Quantity, p.CategoryID,
_categoryID = c.ID,
_categoryName = c.Name
};
var selectedCat = _productCategories
.Where
(x => x._categoryID.ToString() == id)
.SingleOrDefault()._categoryName;
}
modified 25-Jul-16 0:28am.
|
|
|
|
|
I don't see a default if the select fails!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi thanks for replying. Below is my modified code which implements try catch.
public Void MyMethod(string id)
{
List<Product> _products = new List<Product>();
List<Category> _categories = new List<Category>();
_products = psc.FindAllProducts().ToList();
_categories = psc.FindAllCategories().ToList();
ProductCategory selectedCategory = new ProductCategory();
StringBuilder errors = new StringBuilder();
try
{
var _productCategories =
from c in _categories join p in _products
on c.ID equals p.CategoryID
select new
{
p.ID, p.Name, p.CategoryID,
_categoryID = c.ID, _categoryName = c.Name
};
try
{
var selectedCat = _productCategories
.Where(x => x._categoryID == Convert.ToInt32(id))
.SingleOrDefault()._categoryName;
foreach (var pc in _productCategories)
{
if (Convert.ToInt32(id) == pc.CategoryID)
{
selectedCategory.ProductID = pc.ID;
selectedCategory.Name = pc.Name;
selectedCategory.CategoryID = pc._categoryID;
selectedCategory.CategoryName = pc._categoryName;
}
}
}
catch (Exception ex)
{
errors.Append(ex).AppendLine("<br> <br>");
}
}
catch (Exception ex)
{
errors.Append(ex).AppendLine("<br"> <br>");
}
}
modified 25-Jul-16 1:02am.
|
|
|
|
|
I suspect the problem is that the category ID you've passed in doesn't exist. As a result, the SingleOrDefault method returns null , and you then try to retrieve the _categoryName property from that null reference.
If you want the code to fail if the category ID doesn't exist, change the code to use Single instead. Otherwise, you'll need to test the value returned from SingleOrDefault to see if it's null .
You can combine the Where and Single[OrDefault] calls, as both Single[OrDefault] and First[OrDefault] have overloads which accept a filter.
And there's no need to create the two List<T> instances at the start, as you immediately overwrite them on the following lines.
List<Product> _products = psc.FindAllProducts();
List<Category> _categories = psc.FindAllCategories();
var _productCategories =
from c in _categories
join p in _products
on c.ID equals p.CategoryID
select new {
p.ID, p.Name, p.Price,
p.Quantity, p.CategoryID,
_categoryID = c.ID,
_categoryName = c.Name
};
var selectedProductCategory = _productCategories.SingleOrDefault(x => x._categoryID.ToString() == id);
var selectedCat = selectedProductCategory == null ? null : selectedProductCategory._categoryName;
var selectedCat = _productCategories.SingleOrDefault(x => x._categoryID.ToString() == id)?._categoryName;
var selectedCat = _productCategories.Single(x => x._categoryID.ToString() == id)._categoryName;
Also, are you sure there's only ever one product in a given category? If there's more than one, Single[OrDefault] will throw an exception.
And I'm not sure why you're passing the category ID as a string , when it's defined as an int in the model?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you so much for your reply. You were right that the CategoryID passed in from a form did not exist.
That's why I got the null exception when I ran my LINQ query.
|
|
|
|
|
Let's assume we have something like this:
public class Person : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged([CallerMemberName]string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}
*1) Copy of the subscribers really needed?
A lot of time in forums like CP I read we need to make a copy of the subscribers before invoke the handlers. Argumentation: This because theoretically the subscribers can unsubscribe in between...
My doubts, respectively I see only arguments why not to copy:
a.) In a some lot (in most?) of MSDN examples, no copy will be made. So, when MSDN does not do it why should I do it?
b.) In case someone unsubscribes he is not longer interested in the event. Why should I notify him then longer?
c.) My opinion is, that it can be dangerous to inform a subscriber while he unsubscribed and therefore does not expect notifications any longer.
[Edit] Thank you BillWoodruff
Ok, a problem I see now in case I do not make a copy:
In bewteen (if PropertyChanged != null) and invoking PropertyChanged(...) it is possible that one does unsubscribe. Probably this Point is solved in c#6 by using (PropertyChanged?.Invoke(...)
But still "c.)" above is critical I think...(?) and the subscriber has to be aware that even after unsubscribing he can get notifications.
Comments / corrections / notes will be very appreciated.
Thank you in advance.
modified 19-Jan-21 21:04pm.
|
|
|
|
|
I think you may find Jon Skeet's comments on this relevant: [^], and his information on using an extension method, and the null-conditional operator in C#6 ... interesting.
I don't pretend to understand the thread-safety and/or multiple-subscriber issues involved: for that we need Richard Deeming or Richard MacCutchan to step-up
«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
|
|
|
|
|
Thank you for this. I just edited the question a Little bit
modified 19-Jan-21 21:04pm.
|
|
|
|
|
I'm glad that's helpful; perhaps it's a bias of mine that I think copying a pointer is "cheap" ?
«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
|
|
|
|
|
BillWoodruff wrote: we need Richard Deeming or Richard MacCutchan to step-up That's very kind but misguided I'm afraid. I could possibly give an answer, but I would need to do quite a bit of research and testing first.
|
|
|
|
|
I know it is your modesty that makes you suggest I may be kindly misguided to consider you (and brother Deeming) as guides non-pareil in this esoteric area, and I appreciate that quality as much as I do the depth of your technical knowledge Richard MacCutchan wrote: I could possibly give an answer
Duchess to Alice (Alice’s Adventures in Wonderland, Chapter 9) That’s nothing to what I could say if I chose.
«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
|
|
|
|
|
BillWoodruff wrote: know it is your modesty But thank you anyway.
And, to be honest I could not have produced as good an explanation as Pete's below.
|
|
|
|
|
BillWoodruff wrote: we need Richard Deeming or Richard MacCutchan to step-up
Or Pete, who nailed the explanation below. But your link also answers the question, albeit in much greater detail.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Imagine your system has an event with one subscriber. This subscriber is on a background thread. Now, consider the case where the very last action before context switching over to the thread your subscriber is on is to check to see if you have any subscriptions. That's fine as the null check will tell you that you have a subscriber.
Okay, you're now processing on this other thread and the first thing it does is to remove the event subscription. You now have nothing hooked up to the event but when you context switch back, it's going to continue as though there are subscriptions. That's why you take the copy.
This space for rent
|
|
|
|