TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
scott oliver
NA
82
16.2k
Need help with visual studio 2008
Dec 9 2014 6:15 PM
Need help with an old version of visual studio. I am using visual studio express 2008 because of the version of .net i am working with. I am using the below code and it throws me an exception. Seems pretty straight forward but im stumped can any one help?
it throws a issue at the foreach on the "in" saying its an invalid class. havnt seen this one before.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;
using System.Data;
using System.Threading;
using System.Management;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_Product WHERE Name = '" + "Symantec Endpoint Protection" + "'");
foreach (ManagementObject mo in mos.Get())
{
try
{
if (mo["Name"].ToString() == "Symantec Endpoint Protection")
{
object hr = mo.InvokeMethod("Uninstall", null);
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
//this program may not have a name property, so an exception will be thrown
}
try
{
if (mo["Name"].ToString() == "Symantec Endpoint Protection Manager")
{
object hr = mo.InvokeMethod("Uninstall", null);
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
//this program may not have a name property, so an exception will be thrown
}
}
}
}
}
Reply
Answers (
2
)
LSTV Object in a Panel displays scroll bars but don't work
Nested Dictionary looping challenge need help!