Solved

Allow unsafe code

Posted on 2011-03-23
6
993 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
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.

 
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!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET Repostiory Pattern 7 37
Moving code from one TFS branch to another 3 25
VB.NET 2008 Publish Error 2 27
SQL Server Connection String through a VPN 8 29
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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…

831 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