Solved

Allow unsafe code

Posted on 2011-03-23
6
1,003 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Stressed Out?

Watch some penguins on the livecam!

 
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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

688 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