Solved

Allow unsafe code

Posted on 2011-03-23
6
998 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

830 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