See the following code. The test passed when using AutoMapper, but failed when using ValueInjecter:
using NetFwTypeLib;
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
INetFwPolicy2 policy = (INetFwPolicy2)Activator.CreateInstance(
Type.GetTypeFromProgID("HNetCfg.FwPolicy2"));
INetFwRules fwRules = policy.Rules;
Rule rule = new Rule();
foreach (INetFwRule fwRule in fwRules)
{
if (fwRule.Name == "HomeGroup Out")
{
//AutoMapper.Mapper.CreateMap<INetFwRule, Rule>();
//AutoMapper.Mapper.Map(fwRule, rule);
rule.InjectFrom(fwRule);
break;
}
}
Assert.IsTrue(rule.Name == "HomeGroup Out");
}
}
public class Rule
{
public string Name { get; set; }
}
Any ideas? Thanks.
Edit:
Based on Omu's answer, it seems the problem is related to COM objects, not only FirewallAPI.dll classes. So I changed title from "Can't get ValueInjecter to map FirewallAPI.dll classes" to "Can't get ValueInjecter to map COM objects".