Miya
Miya
CC#
Created by boom on 12/6/2022 in #help
❔ Variable Access-Manipulation ?
This
4 replies
CC#
Created by Miya on 11/19/2022 in #help
Need some help with marshal
Thx for help I guess
13 replies
CC#
Created by Miya on 11/19/2022 in #help
Need some help with marshal
thats quite a strange restriction
13 replies
CC#
Created by Miya on 11/19/2022 in #help
Need some help with marshal
why so?
13 replies
CC#
Created by Miya on 11/19/2022 in #help
Need some help with marshal
it probably means that the type of the delegate needs to be not a generic
13 replies
CC#
Created by Miya on 11/19/2022 in #help
Need some help with marshal
oh ,i think i know what happens
13 replies
CC#
Created by Miya on 11/19/2022 in #help
Need some help with marshal
so its the GetFunctionPointerForDelegate throwing an error
13 replies
CC#
Created by Miya on 11/19/2022 in #help
Need some help with marshal
13 replies
CC#
Created by Miya on 11/19/2022 in #help
Need some help with marshal
this seems to happen with any function that has more than 0 arguments
13 replies
CC#
Created by Miya on 11/19/2022 in #help
Need some help with marshal
^
13 replies
CC#
Created by Miya on 11/19/2022 in #help
Need some help with marshal
void* functionPointer = (void*)Marshal.GetFunctionPointerForDelegate(CreateDelegate(theCSFunction,0));
void* functionPointer = (void*)Marshal.GetFunctionPointerForDelegate(CreateDelegate(theCSFunction,0));
where createdelegate is
public static Delegate CreateDelegate(this MethodInfo methodInfo, object target) {
Func<Type[], Type> getType;
var isAction = methodInfo.ReturnType.Equals((typeof(void)));
var types = methodInfo.GetParameters().Select(p => p.ParameterType);
if (isAction) {
getType = Expression.GetActionType;
}
else {
getType = Expression.GetFuncType;
types = types.Concat(new[] { methodInfo.ReturnType });
}
if (methodInfo.IsStatic) {
return Delegate.CreateDelegate(getType(types.ToArray()), methodInfo);
}
return Delegate.CreateDelegate(getType(types.ToArray()), target, methodInfo.Name);
}
public static Delegate CreateDelegate(this MethodInfo methodInfo, object target) {
Func<Type[], Type> getType;
var isAction = methodInfo.ReturnType.Equals((typeof(void)));
var types = methodInfo.GetParameters().Select(p => p.ParameterType);
if (isAction) {
getType = Expression.GetActionType;
}
else {
getType = Expression.GetFuncType;
types = types.Concat(new[] { methodInfo.ReturnType });
}
if (methodInfo.IsStatic) {
return Delegate.CreateDelegate(getType(types.ToArray()), methodInfo);
}
return Delegate.CreateDelegate(getType(types.ToArray()), target, methodInfo.Name);
}
13 replies
CC#
Created by Miya on 11/19/2022 in #help
Need some help with marshal
here
13 replies