Symptom
- Using Crystal Report with WPF in XBAP application
- "UseLegacyV2RuntimeActivationPolicy="true" has been added to the app.config file as per KBase 1525432
Environment
- Crystal Reports for Visual Studio 2010
- Visual Studio 2010
Cause
This problem exists when using a .NET 4.0 XBAP which tries to load a .NET 2.0 (3.5) assembly
Resolution
- Use the following code before initializing the class for the WPF form:
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("BD39D1D2-BA2F-486A-89B0-B4B0CB466891")]
interface ICLRRuntimeInfo {
void xGetVersionString();
void xGetRuntimeDirectory();
void xIsLoaded();
void xIsLoadable();
void xLoadErrorString();
void xLoadLibrary();
void xGetProcAddress();
void xGetInterface();
void xSetDefaultStartupFlags();
void xGetDefaultStartupFlags();
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
void BindAsLegacyV2Runtime();
}
- The add the following:
ICLRRuntimeInfo rtInfo = (ICLRRuntimeInfo)RuntimeEnvironment.GetRuntimeInterfaceAsObject(Guid.Empty, typeofICLRRuntimeInfo).GUID);
rtInfo.BindAsLegacyV2Runtime();
Keywords
CR2010 2010 CR4VS2010 CR4VS VS2010 NET2010 Crystal Reports for .NET Framework 4.0 crforvs 13 dot net dataset data set , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To
Product
SAP Crystal Reports, developer version for Microsoft Visual Studio