Solved

Allow unsafe code

Posted on 2011-03-23
6
988 Views
Last Modified: 2012-05-11
Hi Experts

I have a silverlight 4 project and i have also created a silverlight class library to write code for unsafe classes and to allow me to run this code i need the 'Allow unsafe code' option enabled and it isnt within my build properties tab of the silverlight project. Does anyone know to enable this option?

Thanks
0
Comment
Question by:razza_b
  • 3
  • 3
6 Comments
 
LVL 16

Accepted Solution

by:
Imran Javed Zia earned 500 total points
ID: 35200109
Hi,

SilverLight do not support Unsafe code, please refer to following:
http://forums.silverlight.net/forums/p/2983/164781.aspx

Thanks
0
 
LVL 1

Author Comment

by:razza_b
ID: 35200182
So thats why that option is disabled? Is there no way around this at all?

Thanks
0
 
LVL 1

Author Comment

by:razza_b
ID: 35200244
So if i have written a class within a SL class library and then i cant reference it within a SL project than whats the point??

snippet
namespace Printing
{
    public class UnsafeNativeMethods
    {
        internal enum PrinterType
        {
            Default = 0,
            Win32 = 1,
            Repository = 2,
            Cups = 3,
            PostscriptFile = 4,
            HtmlFile = 5,
            PdfFile = 6,
            PostscriptPrinter = 7,
            TextPrinter = 8,
            TextFile = 9,
            ePrinterType_ImageBmp = 10,
            ePrinterType_ImageGif = 11,
            ePrinterType_ImageJpg = 12,
            ePrinterType_ImagePcx = 13,
            ePrinterType_ImagePng = 14,
            ePrinterType_ImageTga = 15,
            ePrinterType_ImageTifSingle = 16,
            ePrinterType_ImageTifMultiPage = 17,
            ePrinterType_ZPLPrinter = 18,
            ePrinterType_ZPLFile = 19,
            Invalid = 20,

        }
         
         internal enum DataFieldUsage
        {
            NotUsed = 0,
            Normal = 1,
            Calculated = 2,
            Parameter = 3,
            Invalid = 4,

        }

        // If the DLL changes, there is one place to change the version string.
        private const string TFORMER = "TFormer60.dll";

        [DllImport(TFORMER, CharSet = CharSet.Ansi)]
        internal  extern static IntPtr Init(IntPtr hRepository);

        [DllImport(TFORMER, CharSet = CharSet.Ansi)]
        internal  extern static int Exit(IntPtr pInstance);
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 16

Expert Comment

by:Imran Javed Zia
ID: 35200283
It is disabled as SilverLight application can run on non windows os which may not proived or even may not support such things. but if you are interested in printing then you may go through these links:
http://www.davidpoll.com/2010/04/16/making-printing-easier-in-silverlight-4/
http://www.silverlightshow.net/items/Advanced-printing-in-Silverlight-4.aspx
http://www.silverlightshow.net/items/A-look-at-the-Printing-API-in-Silverlight-4.aspx

Thanks
0
 
LVL 1

Author Comment

by:razza_b
ID: 35200351
Thanks for links

My company use a third party printing DLL just for .net to print using zebra thermal printers, but they havnt done it for SL thats why im trying to create something similar to what they have, looks like i just have to find a different company who can.

Cheers!
0
 
LVL 16

Expert Comment

by:Imran Javed Zia
ID: 35200374
Wish you all the best,
If it was helpful then please mark it as Answered
Thanks
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now