views:

145

answers:

2

Why would you need to run regasm and caspol on a .NET component more than once?

I have a COM client that uses a .NET component residing on another machine. Consequently I need to run regasm and caspol on this .NET component. What could cause there to be the need to do this again on the same machine to the same component?

Is the effect of regasm and caspol only temporary? Or can I assume that someone has reset or cleared something on a machine if I am having to do this again?

EDIT: Only capsol needs to be run.

+1  A: 

I don't know that much about caspol, but regasm will write to the registry, so the changes should not "disappear" by themselves, I assume caspol is similar. So it does sound like someone else have been messing about with that computer.

Possibly this could be affected if someone boots the machine and tells it to use "the last known good settings" or whatever it's called.

ho1
A: 

Are you sure that both regasm and caspol need to be re-run? If so, Hans Passant's suggestion of a system restore seems likely. However, if it is just caspol that actually needs to be re-run, a .NET Framework upgrade may be resposible. CAS policy is specific to the version of the .NET CLR under which the component is run, so installing .NET 2.0 on a machine that previously had only 1.x might be causing your problem. The 32- and 64-bit CLRs also use different security policies, so installing an alternate bitness .NET Framework might also cause you assembly to be loaded under an CAS policy that you have not yet tweaked.

Nicole Calinoiu
In fact it is just caspol that needs to be run. The assembly that needs caspol re-run is from a third party. Would the CAS policy on that assembly need tweaking after a .NET upgrade?
Craig Johnston
The version-dependency of CAS policy applies to all assemblies, so it's quite possible.
Nicole Calinoiu