I've the following code in a FIRST dll :
public Task FuncAsync(string a, string b, CancellationToken ct)
{
Task t = new Task
(
() =>
{
Save(a, b, ct);
}, ct
);
t.Start();
return t;
}
private void Save(string a, string b, CancellationToken ct)
{
classA.func(a, b, ct); // DOESNT WORK !
//classA.func(a, c); // WORKS !
}
The method class classA
is in the SECOND dll :
public void func(string a, string b, CancellationToken ct)
{
// some code...
}
public delegate void ProgressHandler(object sender, ProgressArgs progressArgs);
public event ProgressHandler ProgressChanged;
Then, my method FuncAsync is called in a Console Application :
CancellationTokenSource cancelSource = new CancellationTokenSource();
CancellationToken ct = cancelSource.Token;
Task task = B.SaveAsync("", "", ct);
The first DLL include the second, the console application include the first DLL.
This code compiles fine, no warning, no error. But on execution, error on the line : Save(a, b, ct);
Additional information: Could not load type 'ProgressHandler' from assembly 'A.B.C, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' because the method 'func' has no implementation (no RVA).
If I delete the CancellationToken from the code, all is ok.
How can I send my CancellationToken from the Application to the DLL1, then from DLL1 to the DLL2 ?
EDIT :
I forgot to precise that I merge the two DLL in one only with the command :
ILMerge /target:libray dll1Temp.dll dll2.dll /out:dll1.dll /internalize /allowDup /lib:C:\Windows\Microsoft.NET\Framework64\v4.0.30319
del dll1Temp.dll
del dll2.dll
When I don't merge the library, there are no error in my code.