kindofmagic
kindofmagic copied to clipboard
Problems with classes derived from generics.
Currently there is a problem in my project. Here is some code I've written to show it better. Is it my fault or some kind of a bug?
Right now the following source code throws an exception on wrapper.Constructed = DateTime.Now;
. You can see the details below.
Source code:
class Program
{
static void Main(string[] args)
{
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
var wrapper = new Wrapper();//(Wrapper)Activator.CreateInstance(typeof(Wrapper), new A());
wrapper.Value = 12345;
Console.WriteLine("Value:{0}", wrapper.Value);
Console.ReadKey();
}
}
[Notify]
public class Wrapper : AbstractWrapper<String>
{
public int Value { get; set; }
}
public abstract class AbstractWrapper<T> : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
var handler = PropertyChanged;
if (handler != null)
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
public class NotifyAttribute : Attribute { }
Exception:
Message:
Could not execute the method because either the method itself or the containing type is not fully instantiated.
Stack trace:
at TestKindOfMagicReflection.AbstractWrapper`1.OnPropertyChanged(String propertyName) at TestKindOfMagicReflection.Wrapper.set_Value(Int32 value) at TestKindOfMagicReflection.Program.Main(String[] args) in c:\Users\dgo.mcc\Documents\Visual Studio 2013\Projects\TestKindOfMagicReflection\TestKindOfMagicReflection\Program.cs:line 15 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
Приветствую Дмитрий,
Спасибо за интерес к kind of magic. Я с удовольствием разберусь в приведенном вами примере глюка. Оперативно - не обещаю, у меня две недели назад родилась дочка, времени катастрофически не хватает ни на что, ни поспать, ни поесть :)
Но как только у меня выдастся свободная минутка, я гляну.
Вопрос вдогонку, как вы подключаете kind of magic, через nuget? Если да, происходит ли глюк при выключенном KoM?
Viele Grüße aus Frankfurt, Lex
День добрый,
Это вам спасибо за отличную библиотеку, очень удобная. Подключаю как прямой референс на dll. Попробую сам поразбираться. Может у вас есть идеи в какую сторону копать?
Удалось упростить кейс =)