background preloader

C#

Facebook Twitter

Crystal Reports - Tutorial: Creating a User Function Library: Introduction. When developers create a Crystal report in the embedded Crystal Report Designer, they often create formula fields to use in the report.

Crystal Reports - Tutorial: Creating a User Function Library: Introduction

These formula fields consist of variables and functions. The embedded Crystal Report Designer comes with a large collection of existing functions. However, in some scenarios a user may require the ability to create a customized function, in the form of a library that can be distributed across machines. The User Function Library provides this capability. A User Function Library (UFL) is a .NET class library that has the following characteristics: The project name is prefixed with the string "CRUFL". To begin, you create the class library. See Also. Exposing .NET Components to COM. Introduction Working as a developer prior to the advent of the .NET Framework really makes one appreciate the rich number of classes the Framework supports right out of the box.

Many times however one may need to be working in the unmanaged world and would like to invoke one of those readily available classes provided in the managed world. Since I have been playing around with .NET for a while, I have learned many of the great classes available within the .NET Framework. SimonS recently posted a question in the C# forum that made me finish a little research and I wanted to share my finding with everyone here. I had actually been tinkering with this idea for a while but never actually had enough time to finish. The problem is, suppose that I have written a nice library, set of utility functions, etc.. running under the .NET Framework, however I want to use this under pre .NET development environments.

To begin, you will need to include the System.Runtime.InteropServices; namespace. CodeGuru: Securing Managed Assemblies with Native EXE Interoperability. Introduction The Problem Reflection .NET and Interoperability The Solution Proof of Concept Demo Conclusions Introduction While it is easy and fun to use the disassembly features of .NET to disclose the managed assembly contents, it also poses the problem of piracy of otherwise copyrighted content.

CodeGuru: Securing Managed Assemblies with Native EXE Interoperability

The Problem Before you actually take up our final solution, let's first clearly specify what your problem is. Thus, you can safeguard your managed assembly if you can hide its metadata from the dissembler. Reflection The classes required for Reflection are available under the System.Reflection namespace and among them Assemblyis one very important class. Public void LoadAndExecute(string strAssemblyPath){ try { Assembly asm = Assembly.Load(strAssemblyPath); asm.EntryPoint.Invoke(null,null); } catch(Exception ex) { MessageBox.Show(ex.Message); }} The typical entry point for any C# assembly would be main(). .NET and Interoperability The Solution Until now, we traced the following steps:

Reflection - The Code Project - C# Programming. Download demo project - 11.3 Kb Reflection is a notable addition to the .NET Framework.

Reflection - The Code Project - C# Programming

Through Reflection, a program collects and manipulates its own metadata. It is a powerful mechanism to introspect the assemblies and objects at runtime. The Reflection APIs are contained in the System.Reflection namespace. Reflection allows the programmer to inspect and collect information about the type, properties, methods and events of an object and to invoke the methods of that object through the Invoke method. In this article, I will provide examples for the following uses of Reflection: Collecting metadata of an assembly and discovering the types of classes in it. Reflection to find out the assemblies used by a program Output mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 ReflectionDemoCSharp, Version=1.0.1882.29904, Culture=neutral, PublicKeyToken=null The System.AppDomain class represents an application domain. Public static Assembly.Load(AssemblyName)