System.InvalidCastException

Every time I update a file in the APP_CODE folder in asp.net I get the following error.
System.InvalidCastException: [A]TexasClass.TexasTest cannot be cast to [B]TexasClass.TexasTest. Type A originates from 'App_Code.w8xmcutn, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary
ASP.NET Files\root\15ae04a3\80f6a04b\App_Code.w8xmcutn.dll'. Type B originates from 'App_Code.dqtbd99q, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET
Files\root\15ae04a3\80f6a04b\App_Code.dqtbd99q.dll'. at ASP.admin_texesview_aspx.OpenExam(Byte[] bin)
The problem is a duplicate DLL is created when I update a code file. I can resolve it by restarting the server(I did that because I am not sure which file to delete).
Why is this happening and how can I avoid it?

Hi SpaceCityIT,
In my opinion, this thread is related to ASP.NET forum. So please post thread on ASP.NET forum for more effective response. Thank you for understanding. Please refer to the following link.
http://forums.asp.net/.
Regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • CrystalReports  'System.InvalidCastException' occurred

    Hi Team, I'm getting the below error. Can some one please assist me on this? I'm using Windows 2012 R2 server and CrystalReport Runtime 13.0.x version installed on the server. Application built on Any CPU using VisualStudio 2010 Error Message: HandlingInstanceID: c68a0e37-5eb5-4cb5-9587-6d6030b79b48  An exception of type 'System.InvalidCastException' occurred and was caught.  ---------------------------------------------------------------------------  01/13/2015 16:26:11  Type : System.InvalidCastException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089  Message : Unable to cast object of type 'FileStreamDeleteOnClose' to type 'System.IO.MemoryStream'.

    Hi Don,
    I gave this a try and I got the same results I was getting before the change the ExportToStream is returning a object of type FileStreamDeleteOnclose instead of an object of type IO.Stream.
    You have what I had before already, but here is what I changed it to in order to do what the developer asked:
    Protected Friend Function GetPDF(ByVal genColsolidatedPDF As String) As IO.
    Stream
    Dim exportStream As System.IO.Stream = GenerateReport(genColsolidatedPDF).ExportToStream(ExportFormatType
    .PortableDocFormat)
    Using fileStream As New IO.FileStream(expPath, System.IO.FileMode.Create, System.IO.FileAccess
    .Write)exportStream.CopyTo(fileStream)fileStream.Dispose()
    exportStream.Close()
    Return
    exportStream
    End Function
    Private Function GenerateReport(ByVal genConsolPDF As String) As
    ReportDocument
    Dim connInfo As New
    ConnectionInfo
    Dim databaseLoginInfo As New
    TableLogOnInfos
    Dim reportDoc As New
    ReportDocument
    Dim tableSet As
    Tables
    'reportDoc = New ActiveSignatures 
    reportDoc.Load(rptPath)
    reportDoc.SetParameterValue(DAL.ParmName.MRId, BLL.SessionData
    .EssInfo.MRID)reportDoc.SetParameterValue(cCONSOLIDATEPDF, genConsolPDF)
    connInfo.ServerName = [Lib].ApplicationData.db_Server
    connInfo.DatabaseName = [Lib].ApplicationData.db_Name
    connInfo.UserID = [Lib].ApplicationData.db_UserId
    connInfo.Password = [Lib].ApplicationData.db_Password
    tableSet = reportDoc.Database.Tables
    For Each singleTable As Table In
    tableSet
    Dim singleTableLogoninfo As TableLogOnInfo
    = singleTable.LogOnInfo
    singleTableLogoninfo.ConnectionInfo = connInfo
    singleTable.ApplyLogOnInfo(singleTableLogoninfo)
    Next
    Return reportDoc
    End Function
    It seemed like the developer maybe wanted more information about how the report is then used, so this is what happens.  The report is then supposed to be returned as type IO.Stream and then it is to be converted to an IO.MemoryStream: 
    Dim sourceFiles(sourceSize as MemoryStream)
    sourceFiles(i) = New MemoryStream(GetByteArray(CType(parameters.SignaturePage, IO.MemoryStream)))
    parameters.SignaturePage is the crytal report that is being returned, that is what needs to be IO.Stream, but is coming back as FileStreamDeleteOnclose.
    When the application then tries to convert from FileStreamDeleteOnClose to IO.MemoryStream, that is where the error occurrs:  Exception: System.InvalidCastException: Unable to cast object of type 'FileStreamDeleteOnClose' to type 'System.IO.MemoryStream'.  But this is only occurring because I am getting back the incorrect object type from the ExportToStream call. 
    Before I upgraded to SP 13 this worked fine, and has been working fine for years.  It is after SP13 that this ExportToStream stopped giving me the IO.Stream object type and is now returning the FileStreamDeleteOnClose.
    I hope that helps!
    Thank you,
    Leah

  • AppFabric Installation Error System.InvalidCastException

    Hi everyone,
    I tried to install AppFabric on Windows 7 Enterprise (Service Pack1) 64-bit operating system computer.  For development and testing reasons.
    I tried some popular workarounds for appfabric including environment variable changes and others, none of them solved my problem. Can you help me please?
    When i double click WindowsServerAppFabricSetup_x64.exe,  i got System.InvalidCastException which is detailed below.
    Unable to cast COM object of type 'CbsSession' to interface type 'ICbsSession'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{75207391-23F2-4396-85F0-8FDB879ED0ED}' failed due to the following error:
    Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
    Description:
      Stopped working
    Problem signature:
      Problem Event Name: CLR20r3
      Problem Signature 01: setup.exe
      Problem Signature 02: 1.0.0.0
      Problem Signature 03: 4ed52225
      Problem Signature 04: Setup
      Problem Signature 05: 1.0.0.0
      Problem Signature 06: 4ed52225
      Problem Signature 07: 1fb
      Problem Signature 08: 6
      Problem Signature 09: System.InvalidCastException
      OS Version: 6.1.7601.2.1.0.256.4
      Locale ID: 1055

    Hello yilmazuur,
    It looks like your post is not related to Outlook at all. That is why I would recommend asking such questions in the
    AppFabric Service and Workflow Management  forum instead. There you will get the most qualified answers.

  • System.InvalidCastException error

    Hi,
    I have a form with a matrix and an import button. Users can import records from a text file into a user defined table. After the import into table is complete, the form is refreshed with records from the table. It all works fine when there are only a few records. But if it takes longer to import, I get the following error multiple times during form refresh.
    System.InvalidCastExcpet: QueryInterface for interfaceSAPbouiCOM.itemEvent failed at SAPbouiCOM.ItemEventClass.Get_FormUID
    This happens even if the focus is on my form. If I switch to another application, I get this error even if the I import only a few records.
    All the records get imported, the error is only during form refresh.
    Can anybody help? Thanks in advance.
    Thanks,
    Aparna

    Hi Gianluigi,
    Sorry for not posting an update in the past month. I have been trying quite a few things to resolve this issue. I did try using the .Net Profiler but it was not of much use. The only message I get in the profiler is as follows:
    Type: System.Runtime.InteropServices.COMException
    Call: thrown
    Type: System.InvalidCastException
    Call: Thrown
    I think the error is somehow related to UI API and window refresh. But I am not sure what it is. Interestingly, I get the error only while dealing with large data set.
    Thanks,
    Aparna

  • System.InvalidCastException: Operator ' =' is not defined for type 'Byte()' and type 'Integer'.

    I'm getting the following error
    System.InvalidCastException: Operator '>=' is not defined for type 'Byte()' and type 'Integer'.
       at Microsoft.VisualBasic.CompilerServices.Operators.InvokeObjectUserDefinedOperator(UserDefinedOperator Op, Object[] Arguments)
       at Microsoft.VisualBasic.CompilerServices.Operators.InvokeUserDefinedOperator(UserDefinedOperator Op, Object[] Arguments)
       at Microsoft.VisualBasic.CompilerServices.Operators.CompareObjectGreaterEqual(Object Left, Object Right, Boolean TextCompare)
       at Customer_Fee_Calculator.Form1.GetCost2(Object dimension) in C:\Users\Chris\Documents\Visual Studio 2013\Projects\Customer Fee Calculator\Customer Fee Calculator\Form1.vb:line 259
       at Customer_Fee_Calculator.Form1.CustomerSelect_SelectedIndexChanged(Object sender, EventArgs e) in C:\Users\Chris\Documents\Visual Studio 2013\Projects\Customer Fee Calculator\Customer Fee Calculator\Form1.vb:line 72
                Dim inotes = rs1("INOTES").Value
      (Line 72)          If inotes.Length > 1 Then
                    cost = GetCost2(rs1("INOTES").Value)(0)
                    desc = GetCost2(rs1("INOTES").Value)(1)
                Else
                    PkgType = CInt(rs1("PKGTYPE").Value)
                    cost = GetCost(PkgType)(0)
                    desc = GetCost(PkgType)(1)
                End If
     Function GetCost2(dimension)
            Dim tempSql1, rs1
            Dim MyResult As New ArrayList
            Select Case dimension
    (line 259)            Case 1 To 24
                    tempSql1 = "SELECT * FROM PRODUCT WHERE PRODUCTID = 13"
                Case 25 To 43
                    tempSql1 = "SELECT * FROM PRODUCT WHERE PRODUCTID = 14"
                Case 44 To 71
                    tempSql1 = "SELECT * FROM PRODUCT WHERE PRODUCTID = 16"
                Case 72 To 120
                    tempSql1 = "SELECT * FROM PRODUCT WHERE PRODUCTID = 17"
                Case 121 To 499
                    tempSql1 = "SELECT * FROM PRODUCT WHERE PRODUCTID = 18"
                Case 500
                    tempSql1 = "SELECT * FROM PRODUCT WHERE PRODUCTID = 19"
                Case Else
                    tempSql1 = "SELECT * FROM PRODUCT WHERE PRODUCTID = 14"
            End Select
            rs1 = dbconnect(tempSql1, 1)
            MyResult.Add(rs1("RETAIL1").Value)
            MyResult.Add(rs1("DESCRIPTION").Value)
            MyResult.Add(rs1("PRODUCTID").Value)
            rs1 = Nothing
            tempSql1 = Nothing
            Return MyResult
        End Function

    Chris,
    I'm not a database guy - so in many ways, I'm not really qualified to answer this, but I'll make a suggestion anyway:
    At the very top of your code, put the following:
    Option Strict On
    Option Explicit On
    Option Infer Off
    With strict on and infer off, it will force you declare types - which I see missing in many places in the code.
    It's entirely possible that by you then going through and fixing those issues, you'll have corrected the problem.
    I don't know that, but it's possible -- and it should be done this way anyway, so there's certainly no harm to be done; in fact you'll actually speed up the program to a small degree because objects don't have to be inferred for the type that they actually
    are.
    ***** EDIT *****
    Also this: DON'T declare any of the types simply as "Object"; that's just trading off late binding for boxing, so you haven't really done much good. Declare them each as their correct actual type.
    Still lost in code, just at a little higher level.

  • How to overcome: System.InvalidCastException: Unable to cast object of type

    Hi,
    For the database connectivity, we use ODP.Net. In one of the functionality we are trying to bind an array to stored procedures and have it execute for the each iteration of the array as a bulk transaction.
    Not always but, 10% of the times the function has raised the following exception
    System.InvalidCastException: Unable to cast object of type 'System.DateTime[]' to type 'System.IConvertible' .
    Has anyone ever faced such a problem, if someone has a soltuion it would be of great help to me.
    Thanks

    Hi,
    For the database connectivity, we use ODP.Net. In one of the functionality we are trying to bind an array to stored procedures and have it execute for the each iteration of the array as a bulk transaction.
    Not always but, 10% of the times the function has raised the following exception
    System.InvalidCastException: Unable to cast object of type 'System.DateTime[]' to type 'System.IConvertible' .
    Has anyone ever faced such a problem, if someone has a soltuion it would be of great help to me.
    Thanks

  • System.InvalidCastException at DataReader.GetInt64 or DataReader.GetInt16

    Hallo,
    we have an application which gets data from a view in an Oracle 9.2.0.7 database:
    SELECT CAST (1138923 AS NUMBER (10)) AS object_id,
    CAST (MIN.universal_time AS NUMBER (10)) AS universal_time,
    MIN.local_time AS local_time, 0 AS mod_time, 0 AS COUNT,
    CAST ((MIN.VALUE + MAX.VALUE) / 2 AS NUMBER (38, 19)) AS VALUE,
    CAST (9 AS NUMBER (2)) AS flag
    FROM TimeSeries
    WHERE object_id = 1138923
    We access this view with a ODP.NET 9.2.0.7 provider using a DataReader.
    On our development machine and at the most customers the acces works very fine !!
    But only at one customer we get an InvalidCastException iif we use the GetInt64 or GetInt16 DataReader method.
    While debugging we recognized that the datareader method returns a decimal, although it is casted to number 10
    We don't want to use a GetDecimal or CAST command in the .NET code, the view or table should return a double !
    Is this a known behaviour ?
    Many thanks in advance and
    Best regards
    George
    Edited by: hakomdba on 23.02.2009 11:04

    How did you go about recreating the Managed Metadata Service Application? Did you point the service application at the existing database when recreating it or did you create it with a 'dummy' database and use the following PowerShell to point it at
    the old database?
    $app = Get-SPServiceApplication -Name "<ServiceApplicationName>"
    Set-SPMetadataServiceApplication -Identity $app -DatabaseName "<DbName>"
    Also, I have seen scenarios where the MMD service application db is completely corrupt and the only way to retain data is through the commands specified here:
    http://social.technet.microsoft.com/wiki/contents/articles/5233.sharepoint-2010-import-export-termset.aspx
    Regards,
    Andrew J Billings
    Portal Systems Engineer//MCSA,MCSE
    Blog:
    http://www.andrewjbillings.com 
    Twitter:   LinkedIn:
      

  • Unable to cast object of type 'System.Xml.XmlText' to type 'System.Xml.XmlE

    Hi All,
    We just migrated from BPC 5.1 to BPC 7.0 SP6. But when we want to run a package in the data manager we get the following error:
    Exception Text **************
    System.InvalidCastException: Unable to cast object of type 'System.Xml.XmlText' to type 'System.Xml.XmlElement'.
       at OSoft.Consumers.DataMgr.PackageModify50.PackageDetail.LoadDetail(String strXMLString)
       at OSoft.Consumers.DataMgr.PackageModify50.PackageDetail.GetPackageDetailfromServer(String strPackageName, String strPackageFilePath, String strTeamID)
       at OSoft.Consumers.DataMgr.PackageModify50.frmMain.PackageListClickEvent(String strPackageID, String strPackageFileName, String strTeamID)
       at OSoft.Consumers.DataMgr.PackageModify50.frmMain.SetStartUp()
       at OSoft.Consumers.DataMgr.PackageModify50.frmMain.frmMain_Load(Object sender, EventArgs e)
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    Any idea?
    Br
    Steven

    Hi,
    If you were running 5.1 version, that would also mean that you were running packages under SQL 2005.
    And if you are now running SQL 2008 with BPC 7.0, you should also review all your customized packages. In fact, BPC tasks in SSIS are not the same between SQL 2005 and SQL 2008.
    In addition, I would recommend to upgrade your SQL server version to SQL 2008 SP1 cumulative update package 6 (prerequisite). Not sure if you're still running this CU.
    Hope this will help.
    Best Regards,
    Patrick

  • Unexpected InvalidCastException With DataTemplate

    I have the following Xaml for which I set the ItemsSource property as follows:
    <ItemsControl x:Name="itmRecipients" Grid.Column="0" Grid.Row="2" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollMode="Auto" ScrollViewer.BringIntoViewOnFocusChange="True">
    <ItemsControl.ItemsPanel><ItemsPanelTemplate><StackPanel/></ItemsPanelTemplate></ItemsControl.ItemsPanel>
    <ItemsControl.ItemTemplate><DataTemplate><RadioButton Style="{StaticResource BasicToggleButton}" GroupName="Recipients" Checked="Recipient_Checked" Content="{Binding Name}" Tag="{Binding Index}"/></DataTemplate></ItemsControl.ItemTemplate>
    </ItemsControl>
    Me.itmRecipients.ItemsSource = Me.Recipients.Select(Function(r, i) New With {.Name = r.Name, .Index = i})
    As you can see, the DataTemplate is just a RadioButton which uses the Name and Index properties of the bound items. The bound items are an anonymous type with the properties Name and Index. But when I run the code, I get the following error:
    A first chance exception of type 'System.InvalidCastException' occurred in GiftTrackerUnivAppTest_Windows.exe
    After looking at App.g.i.vb, I found the following in unhandledExceptionArgs:
    "System.InvalidCastException: Unable to cast object of type 'VB$AnonymousType_0`2[System.String,System.Int32]' to type 'Windows.UI.Xaml.Controls.RadioButton'.
        at GiftTrackerUnivAppTest_Windows.MainPage.MainPage_Loaded(Object sender, RoutedEventArgs e)"
    'VB$AnonymousType_0`2[System.String,System.Int32]' is obviously my anonymous type with the Name and Index properties. Why is it trying to convert my anonymous type to a RadioButton instead of applying it to the DataTemplate? Thanks.
    Nathan Sokalski [email protected] http://www.nathansokalski.com/

    Hi Nathan,
    I used the following code snippet to test in store app, but I worked. I could not reproduce your problem. Can you post a repro project or post more information to explain your scenario?
    Private Sub Page_Loaded(sender As Object, e As RoutedEventArgs)
    list = New System.Collections.ObjectModel.ObservableCollection(Of Employee)()
    Dim rnd As New Random()
    For i As Integer = 0 To 99
    Dim ee As New Employee()
    ee.Name = "herro" & i.ToString()
    ee.Index = rnd.Next(0, 101)
    list.Add(ee)
    Next
    itmRecipients.ItemsSource = list.Where(Function(w) w.Index > 10).[Select](Function(s) New With { _
    Key .Name = s.Name, _
    Key .Index = s.Index _
    End Sub
    Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate
    the survey.

  • DeltaSynchronization Error 29181 InvalidCastException

    I started getting errors on the DeltaSynchronization but have not been able to determine the cause or who to fix it.
    I have already increased the timeout values in ConfigService.config on all the management servers, although i didn't think this would resolve the issue.
    Any help or suggestions would be appreciated.
    Below is the full error message:
    OpsMgr Management Configuration Service failed to execute 'DeltaSynchronization' engine work item due to the following exception
    Microsoft.EnterpriseManagement.ManagementConfiguration.DataAccessLayer.DataAccessException: Data access operation failed
    at Microsoft.EnterpriseManagement.ManagementConfiguration.DataAccessLayer.DataAccessOperation.ExecuteSynchronously(Int32 timeoutSeconds, WaitHandle stopWaitHandle)
    at Microsoft.EnterpriseManagement.ManagementConfiguration.CmdbOperations.CmdbDataProvider.GetConfigurationDelta(String watermark)
    at Microsoft.EnterpriseManagement.ManagementConfiguration.Engine.TracingConfigurationDataProvider.GetConfigurationDelta(String watermark)
    at Microsoft.EnterpriseManagement.ManagementConfiguration.Engine.DeltaSynchronizationWorkItem.TransferData(String watermark)
    at Microsoft.EnterpriseManagement.ManagementConfiguration.Engine.DeltaSynchronizationWorkItem.ExecuteSharedWorkItem()
    at Microsoft.EnterpriseManagement.ManagementConfiguration.Interop.SharedWorkItem.ExecuteWorkItem()
    at Microsoft.EnterpriseManagement.ManagementConfiguration.Interop.ConfigServiceEngineWorkItem.Execute()
    System.InvalidCastException: Specified cast is not valid.
    at Microsoft.EnterpriseManagement.ManagementConfiguration.CmdbOperations.EntityChangeDeltaReadOperation.ReadManagedEntitiesProperties(SqlDataReader reader)
    at Microsoft.EnterpriseManagement.ManagementConfiguration.CmdbOperations.EntityChangeDeltaReadOperation.ReadData(SqlDataReader reader)
    at Microsoft.EnterpriseManagement.ManagementConfiguration.DataAccessLayer.ReaderSqlCommandOperation.SqlCommandCompleted(IAsyncResult asyncResult)

    Figured it out for my issue. A clustered server created additional windows computer objects with IsVirtualNode set to True, representing the cluster. It's an annoyance, but you need to know how to weed these out if your discovery will be run against Microsoft.Windows.Server.Computer
    and where your SCOM box is monitoring clustered servers.
    My discovery script tries to push the discovered object down to the agent. Which is impossible for these weird virtual computer objects.
        $global:discoveryData.AddInstance($instance)
        # force the seed down the the agent
        # To force the RMS to re-assign the local agent as the managing agent for the discovered physical server object ($instance)
        # we have to get a reference to the local health service class and then create a SPECIAL SECRET relationship :)
        $oHealthServiceInstance = $global:discoveryData.CreateClassInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthService']$")
        $oHealthServiceInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $PrincipalName)
        $global:discoveryData.AddInstance($oHealthServiceInstance)
        $oHsCnRel = $global:discoveryData.CreateRelationshipInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthServiceShouldManageEntity']$")
        $oHsCnRel.Source = $oHealthServiceInstance
        $oHsCnRel.Target = $instance
        $global:discoveryData.AddInstance($oHsCnRel)
    It works find if all your servers are unclustered, but if they're clustered you can't push the object down to the agent, there isn't one.  This seems to be the culprit of the call stack described at the beginning of this discussion.
    So... to fix it (ignore the offending objects) ...
    If you're doing a filtered registry discovery, add this to your filter expression...
          <Expression>
            <SimpleExpression>
              <ValueExpression>
                <Value Type="String">IsVirtualNode:$Target/Property[Type="Windows!Microsoft.Windows.Server.Computer"]/IsVirtualNode$</Value>
              </ValueExpression>
              <Operator>NotEqual</Operator>
              <ValueExpression>
                <Value Type="String">IsVirtualNode:True</Value>
              </ValueExpression>
            </SimpleExpression>
          </Expression>
    The SCOM object returns NULL when the property is not True, so this is the best way to check (by prepending $Target with some token text like 'IsVirtualNode:')   The resulting generated text will be with 'IsVirtualNode:True' for the target objects
    we want to ignore, and 'IsVirtualNode:' for the target objects we want to process (these are the non-virtual, real physical computers that you thought you were getting all along).  If you do not prepend the $Target... with 'IsVirtualNode:'  I've
    seen SCOM not even process this with the expression evaluation, presumably because it's trying to compare a null instead of a generated string (which is what you get with my hack).
    Ok, enough of that...  If you're trying to do discovery with a script, you can do something like this, where you return early with an empty discovery payload otherwise proceed with normal discovery:
        $isvirtualnode = "IsVirtualNode:$Target/Property[Type="Windows!Microsoft.Windows.Server.Computer"]/IsVirtualNode$"
        if ($isvirtualnode -eq "IsVirtualNode:True")
            #Write-ErrorInfo "Tried to discover Active/Idle for $PrincipalName (IsVirtualNode: $isvirtualnode)"
            #return the empty payload back to SCOM
            $discoveryData
            return
        else
            #Write-Info "Tried to discover Active/Idle for $PrincipalName (IsVirtualNode: $isvirtualnode)"
        # proceed with normal discovery
    Hope this helps someone out there. I spent a lot of time learning about how SCOM deals with clusters a few years back. It was quite a painful experience trying to develop a cluster-aware SCOM pack using the minimal white papers that were available. 
    This piece of info that I'm sharing took some digging as it wasn't documented well in the white papers.

  • Bitmap loading generates InvalidCastException

    Hello all,
    i'm on compact framework 2 (CLR Version: 2.0.7045.0), and i keep getting these first chance exceptions (disabled breaking on them) in my code when trying to load a bitmap from a file. However, the bitmap is created correctly.
    I've seen it happen with both jpg and png, others i haven't tried yet.
    Bitmap tmp;
    tmp = new Bitmap(BackgroundImage);
    or silimar ones all generate this.
    A first chance exception of type 'System.InvalidCastException' occurred in System.Drawing.dll
    The error is happening here:
    System.Drawing.dll!Microsoft.AGL.Common.MISC.CreateMemoryStream(System.IO.Stream stream = {System.IO.FileStream}) + 0xb bytes   
    and detailed one is:
    System.InvalidCastException occurred
      Message="InvalidCastException"
      StackTrace:
        at Microsoft.AGL.Common.MISC.CreateMemoryStream()
        at System.Drawing.Bitmap..ctor()
        at OctopusCF.UI.xml.SkinConfig.GetBackgroundImage()
        at Octopuscf.Program.Main()
    Anyone have any idea where they come from? As the bitmap gets created correctly, could it be that something is happening internally in the system.drawing dll, from which it can recover and still load the bitmap?
    Thanks,
    Kristof

    Yes. You should cache bitmaps you're going to reuse not just because of exception but mostly because it takes a long time to decompress bitmaps. Exception take may be 1-2% of that time. Watch out for available memory though, don’t cache too much.

  • InvalidCastException run an execution in WPF host

    i got this error when I ran the execution in my WPF host.
    An exception occurred inside of the call to .NET member 'CreateFromXmlFile': System.InvalidCastException: [A]TsDllCall.Person cannot be cast to [B]TsDllCall.Person. Type A originates from 'TsDllCall, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:xxx\Issues\TsDllHell\bin\Debug\TsDllCall.dll'. Type B originates from 'TsDllCall, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadFrom' at location 'C:\xxx\Issues\TsDllHellSeq\tsdllcall.dll'.
        at TsDllCall.Person.CreateFromXmlFile(String filePath) [Error Code: -17500]
    The WPF host has loaded the TsDllCall.dll. The sequence loaded the DLL from another location. Both DLLs are identical. For a reason they have to be in different location. Somehow TestStand did not realize that the WPF host has loaded the DLL, instead it tried to load it from another location.
    Any idea on how to solve this? I don't want to put them in GAC if possible.
    Thanks.
    Attachments:
    TsDllHell.zip ‏69 KB

    The WPF host is statically linked to the TsDllCall.dll and it uses 'new' operator to create the object. For the function call in the sequence file, it uses XmlSerializer to create the object. It gives no error if I use the 'new' operator to create the object.
    I have created the event handler for AssemblyResolve. It requested the following assembly:
    TsDllCall.XmlSerializers
    TsDllCall.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
    I have genarated the TsDllcall.XmlSerializers.dll using SGen and put it together with the 2 TsDllCall.dll. I load the one used by the sequence file in the event handler but I still get the same error. I'm not sure if I'm doing it correctly.
    However, I have found another solution: http://sixlettervariable.blogspot.com/2007/05/net-xmlserializer-and.html
    Place this in my app.config and the problem has gone.
    <system.diagnostics>
    <switches>
    <add name="XmlSerialization.Compilation" value="4" />
    </switches>
    </system.diagnostics>
    I don't know what is it doing exactly. I will use this solution for now.
    Thanks for the help.

  • RMS error - Unable to cast object of Type 'System.Byte[]' to type 'System.String'

    Hi,
    I'm experiencing an issue when trying to connect to RMS cluster through server manager. Error is:
    Active Directory Rights Management Services could not complete the task because an error occurred. This error may be caused by variable conditions.
    Details:
    Exception message:
    Unable to cast object of type 'System.Byte[]' to type 'System.String'.
    Exception type:
    System.Web.Services.Protocols.SoapExtension (Inner Exception: System.InvalidCastException)
    I've re-installed server, I've reinstalled RMS role, I've tried with and w/o SSL connection to RMS but the error persists. OS is 2008R2 (updated), database is internal (test environment)... 
    Any suggestions?

    Actually there was not problem witg the laptop ! Please ignore this topic. Thanks.

  • InvalidCastException occurred. Return argument has an invalid type in illustrator cs5 VB in VS2012.

    I am writthing a simple illustrator CS5 VB application for testing in VS2012 on Windows7 64-bit. The application can be built succesfully, but got an error at line 2- InvalidCastException occurred. Return argument has an invalid type.
    line 1 - Dim  appref As Illustrator.Application = New Illustrator.Application
    line 2 - Dim myDoc As Illustrator.Document = appref.ActiveDocument
    The detailed errror is
    System.InvalidCastException occurred
      HResult=-2147467262
      Message=Return argument has an invalid type.
      Source=mscorlib
      StackTrace:
           at System.Runtime.Remoting.Proxies.RealProxy.ValidateReturnArg(Object arg, Type paramType)
           at System.Runtime.Remoting.Proxies.RealProxy.PropagateOutParameters(IMessage msg, Object[] outArgs, Object returnValue)...................
    But similar code works in word 2007 macro, so reference to  illustrator CS5 is fine. I think it is caused by .NET Framework 4. Where should I start to solve the problem? Any help is appreciated. Thanks!

    Hello,
    I am getting the same error and I found some articles on Oracle Metalink (Note 360287.1) regarding the filesystemio_options parameter and the mount option cio. Basically it looks as if AIX will not allow another program e.g. cp to access the oracle datafile whilst oracle is accessing it unless you have set the cio option at the filesystem level.
    I haven't tried this yet as I need to get some downtime but I think this is what is causing the problem.
    Be careful if you don't have the Oracle datafiles in seperate filesystems because there is a problem with cio and running binaries. (check the man pages for the cio mount option)
    Hope this helps you.
    Regards
    Garry Bayford.

  • Exchange Web Services (EWS) - InvalidCastException

    I have a service that reads the new emails in an Office 365 Exchange mailbox, and saves attachments in a directory.
    For most emails it runs well, however I'm getting a lot of the following exceptions lately:
    System.InvalidCastException: Unable to cast object of type 'Microsoft.Exchange.WebServices.Data.ItemAttachment' to type 'Microsoft.Exchange.WebServices.Data.FileAttachment'
    I will post a piece of my code, could anyone please have a look and tell me what I need to change? It's .NET 4.0, Visual Studio 2010, Visual Basic and the latest Exchange Web Services api, 2.2.
    Dim sf As SearchFilter = New SearchFilter.SearchFilterCollection(LogicalOperator.And, New SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, False))
    Dim findResults As FindItemsResults(Of Item) = service.FindItems(WellKnownFolderName.Inbox, sf, New ItemView(128))
    If findResults.Count > 0 Then
    Dim items As ServiceResponseCollection(Of GetItemResponse) =
    service.BindToItems(findResults.Select(Function(item) item.Id),
    New PropertySet(BasePropertySet.FirstClassProperties, EmailMessageSchema.From, EmailMessageSchema.Sender, EmailMessageSchema.ToRecipients, EmailMessageSchema.IsRead))
    For Each itItem As Microsoft.Exchange.WebServices.Data.Item In findResults.Items
    If TypeOf itItem Is EmailMessage Then
    Dim mailItem As EmailMessage = DirectCast(itItem, EmailMessage)
    If itItem.HasAttachments Then
    itItem.Load()
    For Each Attachment In itItem.Attachments
    If TypeOf Attachment Is FileAttachment Then
    Dim fa As FileAttachment = itItem.Attachments(0)
    pathAttachment = "c:\temp\" & fa.name 'not actual code, but to make this code readable and to the point
    Try
    fa.Load(pathAttachment) 'save file

    It looks like you've hardcoded to always access the first attachment, when really you want to access the current attachment in the For Each loop. (Unless my VB skills are rusty, which is definitely possible!)
    Dim fa As FileAttachment = itItem.Attachments(0)

Maybe you are looking for

  • Problem in reading excel file

    Hi All, I have a requirement to read records from an excel to an internal table.I am using FM KCD_EXCEL_OLE_TO_INT_CONVERT  to read excel. My problem arises when the program comes across a cell which contains some formulae assigned to it. The FM does

  • 27" imac display acting as two displays

    Can seem to find the answer to this, results lead to howtos on a dual monitor setup. I'd like to know if I get a 27" imac can I have the monitor act as a dual screen setup. Essentially, I would like my windows to load and act the way they do given my

  • Help on ORA-01785: ORDER BY item must be the number of a SELECT-list expres

    Hi Please find the SQL below . I am unable to place ORDER bY upper(column) due to error ORA-01785: ORDER BY item must be the number of a SELECT-list expression. Please help SELECT engn_cnslt_list.cnslt_hcp_id "hcp_id", hcp.first_nm "first_nm", hcp.la

  • CIN - TAXINN and TAXINJ

    Why should we go for TAXINN, what are the advantagous of TAXINN over TAXINN Thanks in Advance

  • Download Failed: 910 Application authorization failure"

    Error 910: Failed to download Hi, I just bought a Torch 9800 second hand and I have a big problem right now, I can download any application, I still have a failed installation error 910! I obviously look good on the forums, it gave this:  http://btsc