Event receiver works perfectly in debug mode, but fails in release mode

Here is my item added event which works perfectly and gives read permission to CCfield user in debug mode, but doesn't give permissions to CCfield user when item added event is triggered in release mode:
base.ItemAdded(properties);
try
SPListItem item = properties.ListItem;
string idnumber = Convert.ToString(properties.ListItem["ID"]);
string itemurl = properties.ListItem.Url;
SPWeb web = properties.Web;
item.BreakRoleInheritance(false, false);
//item.Update();
string ccfield = Convert.ToString(properties.ListItem["EmailCc"]);
string STRFirst = "<" ;
string STRLast = ">";
int Pos1 = ccfield.IndexOf(STRFirst) + STRFirst.Length;
int Pos2 = ccfield.IndexOf(STRLast);
string ccfield1 = ccfield.Substring(Pos1, Pos2 - Pos1);
SPUser user = item.Web.EnsureUser(ccfield1);
SPRoleAssignment roleAssignment = new SPRoleAssignment(user);
roleAssignment.RoleDefinitionBindings.Add(web.RoleDefinitions["Read"]);
item.RoleAssignments.Add(roleAssignment);
catch (Exception e)
throw;
Any help?
sk.Rakhishma

Event receivers run using the permissions of the user who triggered the event. If your user does not have rights to manage permissions then you will need to run your security code with elevated permisisons.
SPSecurity.RunWithElevatedPrivileges(delegate()
{ your code here } )
Note that RunWithElevatedPermissions will not work with Sandbox code.
Mike Smith TechTrainingNotes.blogspot.com
my SP customization book

Similar Messages

  • Project runs Ok in debug mode but not in release mode

    I have an application developed with VC++ 6.0 and measurement studio. The application controls SCXI-1161/1166 relay boards to connect the UUT. The application runs ok in debug mode, but in release mode the application can't drive the relay boards. I have tried to change optimizations mode, it didn't work. Who can tell me how to solve the problem? Thanks!

    It sounds like you have an older version of our SWITCH driver which relies on our DAQ driver. I would recommend uninstalling the Traditional DAQ, DAQmx, and SWITCH drivers and then installing the newest version. At this point you have 2 options:
    1) You can download Traditional DAQ 7.4, DAQmx 7.4, and NI-SWITCH 2.4 drivers bundled together here: ftp://ftp.ni.com/support/daq/pc/ni-daq/7.4/
    2) You can install the latest version: NI-DAQmx 7.5 here: http://digital.ni.com/softlib.nsf/websearch/CF7ECC​EA4C4CC7DE86257038004D88AE?opendocument&node=13206​... This has support for all of our USB DAQ devices (if you're not using them then you may not want to worry about installing this now) and then install Traditional DAQ 7.4 here: http://digital.ni.com/softlib.nsf/websearch/C36A54​ADDA3DC33D86257038004E55E6?opendocument&node=13206​... and NI-SWITCH 2.4 here: http://digital.ni.com/softlib.nsf/websearch/9D6B8C​7FD41BF3D08625702E0072E294?opendocument&node=13206​...
    This should solve your problem.

  • G4 iBook works in Safe Mode, but not in regular mode (stuck on blue screen)

    14" iBook G4 1.2GHz with 1 gig of RAM.
    I recently had an issue with this machine in that the image on the screen would freeze but the cursor would be able to move around. This was narrowed down to an issue with the logic board. I wanted something a little more permanent than a shim, so I sent the board in to have it reballed.
    After installing the maching back into my iBook, it seemed to work fine until I applied a software update to the machine.
    It was then that I got to experience the first of many kernel panics.
    Restarting at different times always brought me to the dialog box which states that the machine needed to be restarted in multiple languages.
    Running the Apple Hardware Test off my install disks yielded this error code: 2ATI/2/4:113-xxxxx-125
    I have no idea what that means. I do know that just before I got the results of the test, the screen changed to all kinds of colors. It was only for a few seconds and then the results (with the error code) were displayed.
    Still, not sure what to do next, I tried resetting the PRAM. I also tried resetting the NVRAM.
    I also tried booting up into Safe Mode which actually worked. There were no issues with the machine and everything seemed to be working fine.
    When I tried to restart the machine in regular mode, I'm taken to the infamous blue screen and the machine just stays there. When I let the machine stay off overnight, it booted up normal, but after applying the software update, the machine was in kernel panic again.
    I've tried running fsck, but nothing changes.
    I'm still not sure why it seems to work in Safe Mode but not in regular mode.
    I'd appreciate any suggestions or ideas.

    Hi,
    A couple of the things that are disabled in safe mode are AirPort and non Apple startup items. The easiest thing for you to test is the AirPort card. Shut down and remove the AE card under the keyboard. See if it starts. If it does your AE card is bad. If not, start in safe mode and go to System Preferences>Accounts>youraccount and disable all non Apple startup (LOgin) items by clicking on them and then the minus sign. Restart normally and see if it will start.
    John

  • Cannot access the iCloud mail for some reason I don´t know. Worked perfect until Nov 28th, but a message with "incorrect ID/password" popped up. Contacts and iCal is accessible. Have tried from iPad, Mac, iPhone and PC. Any recommendations?

    Cannot access the iCloud mail for some reason I don´t know. Worked perfect until Nov 28th, but a message with "incorrect ID/password" popped up. Contacts and iCal is accessible. Have tried from iPad, Mac, iPhone and PC. Any recommendations?

    Reset your password. Be sure your new one meets the requirements for length (8) and characters (at least one upper case and one number).

  • Java mapping in ccBPM works in PI 7.0 but fails in PI 7.1

    Hi guys,
    at the moment we are upgrading form SAP PI 7.0 to SAP PI 7.11.
    In a scenario for processing of incoming orders we use an ccBPM.
    In this ccBPM there is an mapping where the original xml document of the order are combined with some
    additional information form an web service (multi mapping 2 => 1)
    The result of this mapping is processed further to create an sales order in the backend.
    The multi mapping an java mapping is used.
    Now we are testing the scenario with PI 7.11 and it fails at this mapping step.
    in the workflow log following error occurs.
    An exception with the type CX_ST_MATCH_ELEMENT occ urred, but was neither handled locally, nor de
    Message no. W8899
    I tested the same message on out SAP PI 7.0 system and the whole ccBPM works well.
    When I extract the 2 messages from workflow log and paste them into the test tab of the operation mapping of Enterprise Service Builder of SAP PI 7.11, surrounding by the envelope used by multi mappings
    <ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
       <ns0:Message1>
                   XML MESSAGE 1
       </ns0:Message1>
       <ns0:Message2>
                   XML MESSAGE 2  
       </ns0:Message2>
    </ns0:Messages>
    the mapping works without error, but at runtime it fails, throwing the error mentioned above.
    What could be the reason for this error?
    Does the multi mapping change in PI 7.11 at runtime?
    Could it be a problem parsing the multi message?
    Any help appreciated.
    Kind regards
    Jochen

    Hi Raja,
    thanks for your suggest.
    I know this issue, the java class files are compiled using jdk 1.5.
    We made some more tests.
    e.g. created an dummy ccBPM with two mappings, one two spilt the incoming message in two messages (graphical message mapping) and one to merge this two messages to one message again (java mapping)
    the mapping works at design time on test tab, but fails with the same error at rumtime.
    Also we tested one single operation mapping with this two mappings (split via graphical mapping and merge via java mapping)
    This works also at design time but fails at runtime with a similar error shown in smq2
    The error message is Error ST_MATCH_FAIL occured. P1=element-start P2=M
    we tried to add the whole incoming message to the trace by
    getTrace().addWarning()
    but an trace object is never created in for this step in the workflow log.
    it seem whether you can not add trace messages using the command or that the error occures before this command will be used.
    Kind regards
    Jochen

  • DNG conversion 6.6 works on my XP system, but fails to see files on my Vista OS.

    DNG conversion 6.6 works on my XP system, but fails to see files on my Vista OS. Same goes for older versions of DNG.  I use the same setup of security on both systems.
    Can anyone help?

    Run an Apple Hardware test.  That may provide a clue:
    http://support.apple.com/en-us/HT201257
    Note that an error free AHT is not definitive.
    If you have all of your data backed up or an external clone HDD, I would try erasing the internal HDD,  reinstalling the OSX and then upgrading the software to 10.6.8.
    Ciao.

  • OSX Mountain Lion 10.8.4: imessage works fine in safe mode, but not in "normal" mode. Any hints?

    My iMessages does not work in "normal" startup, but it works perfectly in safe mode.
    Any hints?
    I have the same problem on a MacBook Pro 17" and on a MacAir 13" mid 2011.
    On my MacMini, iMessage work's fine.
    I'm using same apple ID on all 3 devices.
    Before update to 10.8.4, i had no problems.
    FaceTime also stopped working after update to 10.8.4.
    Thanks in Advance,
    Lars O.

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It won’t solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    Third-party system modifications are a common cause of usability problems. By a “system modification,” I mean software that affects the operation of other software — potentially for the worse. The following procedure will help identify which such modifications you've installed. Don’t be alarmed by the complexity of these instructions — they’re easy to carry out and won’t change anything on your Mac. 
    These steps are to be taken while booted in “normal” mode, not in safe mode. If you’re now running in safe mode, reboot as usual before continuing. 
    Below are instructions to enter some UNIX shell commands. The commands are harmless, but they must be entered exactly as given in order to work. If you have doubts about the safety of the procedure suggested here, search this site for other discussions in which it’s been followed without any report of ill effects. 
    Some of the commands will line-wrap or scroll in your browser, but each one is really just a single line, all of which must be selected. You can accomplish this easily by triple-clicking anywhere in the line. The whole line will highlight, and you can then copy it. The headings “Step 1” and so on are not part of the commands. 
    Note: If you have more than one user account, Step 2 must be taken as an administrator. Ordinarily that would be the user created automatically when you booted the system for the first time. The other steps should be taken as the user who has the problem, if different. Most personal Macs have only one user, and in that case this paragraph doesn’t apply. 
    Launch the Terminal application in any of the following ways: 
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.) 
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens. 
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid. 
    When you launch Terminal, a text window will open with a line already in it, ending either in a dollar sign (“$”) or a percent sign (“%”). If you get the percent sign, enter “sh” and press return. You should then get a new line ending in a dollar sign. 
    Step 1 
    Triple-click the line of text below on this page to select it:
    kextstat -kl | awk '!/com\.apple/{printf "%s %s\n", $6, $7}' | open -f -a TextEdit 
    Copy the selected text to the Clipboard by pressing the key combination command-C. Then click anywhere in the Terminal window and paste (command-V). A TextEdit window will open with the output of the command. If the command produced no output, the window will be empty. Post the contents of the TextEdit window (not the Terminal window), if any — the text, please, not a screenshot. You can then close the TextEdit window. The title of the window doesn't matter, and you don't need to post that. No typing is involved in this step.
    Step 2 
    Repeat with this line:
    { sudo launchctl list | sed 1d | awk '!/0x|com\.(apple|openssh|vix)|org\.(amav|apac|cups|isc|ntp|postf|x)/{print $3}'; sudo defaults read com.apple.loginwindow LoginHook; sudo crontab -l; } 2> /dev/null | open -f -a TextEdit 
    This time you'll be prompted for your login password, which you do have to type. Nothing will be displayed when you type it. Type it carefully and then press return. You may get a one-time warning to be careful. Heed that warning, but don't post it. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator. 
    Note: If you don’t have a login password, you’ll need to set one before taking this step. If that’s not possible, skip to the next step. 
    Step 3
    { launchctl list | sed 1d | awk '!/0x|com\.apple|org\.(x|openbsd)/{print $3}'; crontab -l 2> /dev/null; } | open -f -a TextEdit 
    Step 4
    ls -A /e*/{la,mach}* {,/}L*/{Ad,Compon,Ex,Fram,In,Keyb,La,Mail/Bu,P*P,Priv,Qu,Scripti,Servi,Spo,Sta}* L*/Fonts .la* 2> /dev/null | open -f -a TextEdit  
    Important: If you formerly synchronized with a MobileMe account, your me.com email address may appear in the output of the above command. If so, anonymize it before posting. 
    Step 5
    osascript -e 'tell application "System Events" to get name of every login item' | open -f -a TextEdit 
    Remember, steps 1-5 are all copy-and-paste — no typing, except your password. Also remember to post the output. 
    You can then quit Terminal.

  • Please help my flv video file works perfectly localy...but its not visible in remote ftp why??

    hi All,
    Please help me. my flv video file works perfectly localy in
    my computer...but its not visible when i uploaded the flv html and
    flash files to ftp?
    thanks in advance

    This suggestion worked to see the hidden folder(s). Thanks very much, but I feel like I am miles away from moving my ipod music to my new computer and getting it all to work. Here is why...
    1. First when I plug the ipod in, in disk mode, to the USB slot it shows up as a K drive for a minute or so and then disappears. itunes keeps opening, asking me to sync (which will erase all my music on the ipod!) and the K drive (ipod) vanishes.
    2. I pod help says to drag the itunes file out to the desktop and then drag the itunes file on the ipod into the "my music" file within documents and settings. However, there is an "ipod control" file (was hidden) and within this there is the following: artwork, itunes (with 13 subfolders of its own), device, and music. So do I just drag the itunes file inside ipod control into My music? Or do I drag the whole ipod control file? or other?
    3. Additionally there are K drive (ipod) files for calendar, photos, contacts, notes, and ipod control (was hidden). I don't care about any content in the first four, but are they needed to operate? Do I drag these over also to the My music file?
    Whew, very frustrating. Thanks, Ric

  • I have 2 emai accounts which worked perfectly on iphone 4 but on iphone 5 my msn account wont let me reply to emails sent to that account, it leaves the message in my outbox saying recipient was rejected by the server because it does not allow relaying

    I have 2 email accounts which both worked perfectly well on my ipone 4 but since going over to iphone 5 my msn account will not allow me to reply to any emails. It places a message on my screen stating a copy has been placed in your Outbox. The recipient   @.com was rejected by the server because it does not allow relaying. Any ideas on how I can sort this. Would it be worth deleting my MSN account ant putting re-inputting the details again?

    Your email provider has blocked the standard mail port 25 for sending emails and is requiring a different port. This is to avoid mail relays that use mail clients to send spam. You need to find the port that is used by your provider for sending outgoing mail. Then change the settings in your email account on your phone to match the port. You will also have to provide some security credentials for the account.
    You can also try deleting the email account from your iphone, and the adding the email account back as this will many times set the correct port for sending emails.
    You could also do a Google search on the the settings for your device with your email provider. That will provide you with the proper settings.

  • ITunes 10.7 and AS working perfectly on Mavericks! But now I want to add an iPod-

    Somehow— I don't know how or why— my computer running Mavericks is completely happy with iTunes 10.7 installed, and the App Store apparently works perfectly! I'm very, very happy about this (and happy with Apple lately for other reasons) because I don't like iTunes 11.
    My question is, in previous installations neither the App Store nor my 2011 iPod Touch would work under iTunes 10.7 and Mavericks, and I had always assumed they were probably broken for the same various reasons (e.g., the CoreFP.framework, etc.). Since the App Store suddenly works on this new installation despite having iTunes 10.7, will adding my iPod 1) work also, 2) work also but screw something up such as the App Store, 3) not work, or 4) not work and screw up the App Store. Currently, I use a different ancient laptop to sync with and I ferry content over as I need to— I would truly be in heaven if I could use it with the new computer, but I absolutely don't want to risk losing the perfection I now have… I'd rather have this crippled, complicated iPod problem instead.
    In addition, I'd be perfectly happy with reverting my iPod system software back to whatever best version that will let me do this, assuming that's even possible. If this approach is a good idea, what ios system version do I want (that is happy with 10.7)
    Thank you

    You, the computer operator, are the main user of iTunes. You can sync some or all of your library to as many devices as you have. Each can have different selections of content.
    tt2

  • Upload functin works in Edit mode but not in View mode

    I am using the Oracle AS 10g PDK to integrate struts application into Portal. I found the upload function works fine in portlet edit mode, but it doesn't work in view mode (Go to the "The page cannot be found" and URL is "http://servername/portal/page"). Does anybody know the reason.

    Hi there
    Can you post a screen capture of what your Timeline looks like?
    Odds are your Click Box is pausing in a weird place.
    Cheers... Rick
    Helpful and Handy Links
    Begin learning Captivate 5 moments from now! $29.95
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcererStone Blog
    Captivate eBooks

  • BDC works in A-mode but not in N-mode.  Why?

    We recently upgraded from 4.6b to ERP6.  I have a BDC that fails in ERP6 so I am trying to rework it.  Something odd is happening.  I find that some BDCs run through find in A-mode while you're stepping through them but not in N-mode when it's hands-off.
    Here's the really odd thing.  I have re-recorded a BDC against tran CO01 that creates a PP work order.  I take the recording and product a function.  I test the function with all of the default values intact accept for the new work order# and the function runs in A-mode.  It FAILs in N-mode.  It appears that ERP6 cannot run it's own BDC recordings.
    I notice in A-mode that there are sometimes green info messages on the status line.  What I'm wondering is if these are ok in A-mode because I can hit enter and move on vs. N-mode that perhaps gets stuck on them.  I say that because I have seen BDCs fail and report in the MSGTAB information messages as though this is what caused the transaction to fail.
    Is there some config setting in ERP6 that tells BDCs globally not to fail because of informational status messages?
    Thank you.
    Crew

    Hi,
    this may be an issue if you or the transaction is doing any updates on screens which may fail as call transaction by default updates in the asynchronous mode...
    so try executing the call transaction in synchronous mode and then check if its giving you the same error message.
    use
    call transaction 'TCODE' using bdcdata mode 'N' update 'S'.
    Regards,
    Siddarth

  • Dvd-r's work perfectly on my macbook but some dont work on a PC and an imac

    i've burned 5 dvd-r's (using idvd) over the past few weeks, checking them all on my macbook before taking them to work for presentations.
    2 of the 5 have worked perfectly on the work PC and imacs but 3 have just shown up as blank dvd's on both the imacs and the PC. All work perfectly on my macbook!
    Anyone got any ideas why this is happening? And what I can do to prevent it? The first week was a nightmare but i managed to make the presentation work anyway, this week, luckily the majority of video was on the disk that worked but another disk was just seen as blank by the PC and imac..
    Next week, I'll be taking all the video elements of the presentation on a hard drive as well but its not ideal... Any ideas??

    i dont think its either of those though...
    The media is from the same batch i've been using for a while (and TY dye so not cheap) and two of the five i made worked perfectly in these computers.
    It wasn't just the PC either. An iMac wouldnt recognise them either.
    My macbook still plays them all fine.
    Could it be the dvd burner in my macbook is not compatible with newer machines? My macbook is from mid 2008 and the iMac I tried it on are newer than that.
    I'm also wondering if my macbook burner has a dirty lens? If it does, could that cause these problems??
    Thanks for getting back to me!

  • Drivers Work Perfectly in Windows 8 but NOT in Windows 8.1

    Due to several reasons, most of which pertain to Windows Store app compatibility, I want to upgrade to Windows 8.1. However, I tested the preview beforehand to make sure everything driver-wise was compatible... Everything is fine, except for my Atheros
    AR9285 wifi adapter. For reasons a bit to complicated to explain in this paragraph, I am using the Windows XP driver for this adapter. Please don't say the driver is too old, and that's why it's not working, because I am well versed in drivers and versioning.
    BTW, this driver works perfectly in Windows 8. Just NOT in Windows 8.1. Any help would be appreciated as I am currently ripping my hair out.

    yes, I think also found that
    https://www.atheros.cz/atheros-wireless-download.php?chipset=37&system=7
    try to check if this driver can be run in compatibility mode
    http://www.eightforums.com/tutorials/6832-compatibility-mode-use-windows-8-a.html
    the one that can confirmed is the manufactured. Anyway good luck and let us know the update
    Your reply maybe will be helpful to the others

  • Applet working perfectly in the appletviewer but not in the browser

    I have tried everthing that came upto mind to get the applet working in the browser, which includes
    using of the HTML Converter, downloading the java plugin, newest netscape nevigator6.23 and installing j2sdk 14. still i am unable to get the applet working in the browser where as it works perfectly fine in the appletviewer. Applet takes the gif name and the time deplay to dipaly the pictures after the delay.

    Can we see the HTML source code .and hope ur using the <object > or <embed> tag ..

Maybe you are looking for

  • Print using LPR to Hewlett Packard Designjet 120nr

    I am attempting to set up an LPR connection from OS X 10.5.2 to a Windows 2003 Server based queue. When I add the printer, I am prompted for Server and queue name, this aspect is fine and I have set up other networked printers using this method o.k.

  • Creating a linked image in your email signature

    Since you cannot add a URL link to an image directly in the Prefs/Signature window, do the following: 1. Open a new message window. Paste (or drag & drop) any suitable image. Highlight it. 2. Go to Menu>Edit>Link>Add... and type or paste your URL lin

  • Use iWeb '09 with Google Blog or Wordpress

    it's possible to use iWeb '09 with Google Blog or Wordpress? If it's possible, how? I'm still new to iWeb and blogging... Hope someone can help me with this...

  • Can I play avi files in qt?

    Does qt pro convert avi files to play on appletv?

  • Screen Saver - Apple - Word of the day - Switching to Spanish

    Hello, There is an options button in System Preferences -> Screen Saver -> Apple -> Word of the day where I could choose from different dictionaries. I'm looking for basic Spanish, but it's not there. There must be a way to set it up that way. Any su